home *** CD-ROM | disk | FTP | other *** search
open in:
MacOS 8.1
|
Win98
|
DOS
view JSON data
|
view as text
This file was processed as: LaTeX Document
(document/latex).
You can browse this item here: Appendix-C.tex
Confidence | Program | Detection | Match Type | Support
|
---|
100%
| dexvert
| LaTeX Document (document/latex)
| magic
| Supported |
1%
| dexvert
| Corel 10 Texture (image/corel10Texture)
| ext
| Unsupported |
1%
| dexvert
| Croteam texture file (image/croteamTextureFile)
| ext
| Unsupported |
1%
| dexvert
| Text File (text/txt)
| fallback
| Supported |
100%
| file
| LaTeX document text
| default
| |
99%
| file
| LaTeX document, ASCII text
| default
| |
100%
| checkBytes
| Printable ASCII
| default
| |
100%
| perlTextCheck
| Likely Text (Perl)
| default
| |
100%
| siegfried
| fmt/281 LaTeX (Subdocument)
| default
| |
100%
| detectItEasy
| Format: plain text[LF]
| default (weak)
| |
100%
| xdgMime
| text/x-matlab
| default (weak)
|
|
hex view+--------+-------------------------+-------------------------+--------+--------+
|00000000| 25 0a 25 20 53 54 6b 20 | 52 65 66 65 72 65 6e 63 |%.% STk |Referenc|
|00000010| 65 20 6d 61 6e 75 61 6c | 20 28 41 70 70 65 6e 64 |e manual| (Append|
|00000020| 69 78 3a 20 41 6e 20 49 | 6e 74 72 6f 64 75 74 69 |ix: An I|ntroduti|
|00000030| 6f 6e 20 74 6f 20 53 54 | 6b 6c 6f 73 29 0a 25 0a |on to ST|klos).%.|
|00000040| 25 20 20 20 20 20 20 20 | 20 20 20 20 41 75 74 68 |% | Auth|
|00000050| 6f 72 3a 20 45 72 69 63 | 6b 20 47 61 6c 6c 65 73 |or: Eric|k Galles|
|00000060| 69 6f 20 5b 65 67 40 75 | 6e 69 63 65 2e 66 72 5d |io [eg@u|nice.fr]|
|00000070| 0a 25 20 20 20 20 43 72 | 65 61 74 69 6f 6e 20 64 |.% Cr|eation d|
|00000080| 61 74 65 3a 20 32 32 2d | 4d 61 79 2d 31 39 39 34 |ate: 22-|May-1994|
|00000090| 20 32 32 3a 31 33 0a 25 | 20 4c 61 73 74 20 66 69 | 22:13.%| Last fi|
|000000a0| 6c 65 20 75 70 64 61 74 | 65 3a 20 32 31 2d 4a 61 |le updat|e: 21-Ja|
|000000b0| 6e 2d 31 39 39 36 20 31 | 37 3a 33 35 0a 25 0a 0a |n-1996 1|7:35.%..|
|000000c0| 5c 73 65 63 74 69 6f 6e | 7b 49 6e 74 72 6f 64 75 |\section|{Introdu|
|000000d0| 63 74 69 6f 6e 7d 0a 0a | 7b 5c 73 74 6b 6c 6f 73 |ction}..|{\stklos|
|000000e0| 7d 20 69 73 20 74 68 65 | 20 6f 62 6a 65 63 74 20 |} is the| object |
|000000f0| 6f 72 69 65 6e 74 65 64 | 20 6c 61 79 65 72 20 6f |oriented| layer o|
|00000100| 66 20 7b 5c 73 74 6b 7d | 2e 20 49 74 73 20 69 6d |f {\stk}|. Its im|
|00000110| 70 6c 65 6d 65 6e 74 61 | 74 69 6f 6e 20 69 73 0a |plementa|tion is.|
|00000120| 64 65 72 69 76 65 64 20 | 66 72 6f 6d 20 76 65 72 |derived |from ver|
|00000130| 73 69 6f 6e 20 31 2e 33 | 20 6f 66 20 74 68 65 20 |sion 1.3| of the |
|00000140| 47 72 65 67 6f 72 20 4b | 69 63 6b 7a 61 6c 65 73 |Gregor K|ickzales|
|00000150| 20 54 69 6e 79 20 43 6c | 6f 73 0a 70 61 63 6b 61 | Tiny Cl|os.packa|
|00000160| 67 65 7e 5c 63 69 74 65 | 7b 54 69 6e 79 2d 43 6c |ge~\cite|{Tiny-Cl|
|00000170| 6f 73 7d 2e 20 20 48 6f | 77 65 76 65 72 2c 20 69 |os}. Ho|wever, i|
|00000180| 74 20 68 61 73 20 62 65 | 65 6e 20 65 78 74 65 6e |t has be|en exten|
|00000190| 64 65 64 20 74 6f 20 62 | 65 20 61 73 20 63 6c 6f |ded to b|e as clo|
|000001a0| 73 65 20 61 73 0a 70 6f | 73 73 69 62 6c 65 20 74 |se as.po|ssible t|
|000001b0| 6f 20 43 4c 4f 53 2c 20 | 74 68 65 20 43 6f 6d 6d |o CLOS, |the Comm|
|000001c0| 6f 6e 20 4c 69 73 70 20 | 4f 62 6a 65 63 74 20 53 |on Lisp |Object S|
|000001d0| 79 73 74 65 6d 7b 5c 63 | 69 74 65 7b 43 4c 74 4c |ystem{\c|ite{CLtL|
|000001e0| 32 7d 7d 2e 20 53 6f 6d | 65 20 66 65 61 74 75 72 |2}}. Som|e featur|
|000001f0| 65 73 0a 6f 66 20 7b 5c | 73 74 6b 6c 6f 73 7d 20 |es.of {\|stklos} |
|00000200| 61 72 65 20 61 6c 73 6f | 20 69 73 73 75 65 64 20 |are also| issued |
|00000210| 66 72 6f 6d 20 44 79 6c | 61 6e 7b 5c 63 69 74 65 |from Dyl|an{\cite|
|00000220| 7b 44 79 6c 61 6e 7d 7d | 20 6f 72 20 53 4f 53 7b |{Dylan}}| or SOS{|
|00000230| 5c 63 69 74 65 7b 53 4f | 53 7d 7d 2e 0a 0a 42 72 |\cite{SO|S}}...Br|
|00000240| 69 65 66 6c 79 20 73 74 | 61 74 65 64 2c 20 74 68 |iefly st|ated, th|
|00000250| 65 20 7b 5c 73 74 6b 6c | 6f 73 7d 20 65 78 74 65 |e {\stkl|os} exte|
|00000260| 6e 73 69 6f 6e 20 67 69 | 76 65 73 20 74 68 65 20 |nsion gi|ves the |
|00000270| 75 73 65 72 20 61 20 66 | 75 6c 6c 20 6f 62 6a 65 |user a f|ull obje|
|00000280| 63 74 0a 6f 72 69 65 6e | 74 65 64 20 73 79 73 74 |ct.orien|ted syst|
|00000290| 65 6d 20 77 69 74 68 20 | 6d 65 74 61 2d 63 6c 61 |em with |meta-cla|
|000002a0| 73 73 65 73 2c 20 6d 75 | 6c 74 69 70 6c 65 20 69 |sses, mu|ltiple i|
|000002b0| 6e 68 65 72 69 74 61 6e | 63 65 2c 20 67 65 6e 65 |nheritan|ce, gene|
|000002c0| 72 69 63 0a 66 75 6e 63 | 74 69 6f 6e 73 20 61 6e |ric.func|tions an|
|000002d0| 64 20 6d 75 6c 74 69 2d | 6d 65 74 68 6f 64 73 2e |d multi-|methods.|
|000002e0| 20 20 46 75 72 74 68 65 | 72 6d 6f 72 65 2c 20 74 | Furthe|rmore, t|
|000002f0| 68 65 20 77 68 6f 6c 65 | 20 69 6d 70 6c 65 6d 65 |he whole| impleme|
|00000300| 6e 74 61 74 69 6f 6e 0a | 72 65 6c 69 65 73 20 6f |ntation.|relies o|
|00000310| 6e 20 61 20 74 72 75 65 | 20 6d 65 74 61 20 6f 62 |n a true| meta ob|
|00000320| 6a 65 63 74 20 70 72 6f | 74 6f 63 6f 6c 2c 20 69 |ject pro|tocol, i|
|00000330| 6e 20 74 68 65 20 73 70 | 69 72 69 74 20 6f 66 20 |n the sp|irit of |
|00000340| 74 68 65 20 6f 6e 65 0a | 64 65 66 69 6e 65 64 20 |the one.|defined |
|00000350| 66 6f 72 20 43 4c 4f 53 | 5c 63 69 74 65 7b 41 4d |for CLOS|\cite{AM|
|00000360| 4f 50 7d 2e 20 54 68 69 | 73 20 6d 6f 64 65 6c 20 |OP}. Thi|s model |
|00000370| 68 61 73 20 61 6c 73 6f | 20 62 65 65 6e 20 75 73 |has also| been us|
|00000380| 65 64 20 74 6f 20 65 6d | 62 6f 64 79 0a 74 68 65 |ed to em|body.the|
|00000390| 20 70 72 65 64 65 66 69 | 6e 65 64 20 54 6b 20 77 | predefi|ned Tk w|
|000003a0| 69 64 67 65 74 73 20 69 | 6e 20 61 20 68 69 65 72 |idgets i|n a hier|
|000003b0| 61 72 63 68 79 20 6f 66 | 20 7b 5c 73 74 6b 6c 6f |archy of| {\stklo|
|000003c0| 73 7d 20 63 6c 61 73 73 | 65 73 2e 20 54 68 69 73 |s} class|es. This|
|000003d0| 0a 73 65 74 20 6f 66 20 | 63 6c 61 73 73 65 73 20 |.set of |classes |
|000003e0| 70 65 72 6d 69 74 73 20 | 74 6f 20 73 69 6d 70 6c |permits |to simpl|
|000003f0| 69 66 79 20 74 68 65 20 | 63 6f 72 65 20 54 6b 20 |ify the |core Tk |
|00000400| 75 73 61 67 65 20 62 79 | 20 70 72 6f 76 69 64 69 |usage by| providi|
|00000410| 6e 67 0a 68 6f 6d 6f 67 | 65 6e 65 6f 75 73 20 61 |ng.homog|eneous a|
|00000420| 63 63 65 73 73 65 73 20 | 74 6f 20 77 69 64 67 65 |ccesses |to widge|
|00000430| 74 20 6f 70 74 69 6f 6e | 73 20 61 6e 64 20 62 79 |t option|s and by|
|00000440| 20 68 69 64 69 6e 67 20 | 74 68 65 20 6c 6f 77 20 | hiding |the low |
|00000450| 6c 65 76 65 6c 0a 64 65 | 74 61 69 6c 73 20 6f 66 |level.de|tails of|
|00000460| 20 54 6b 20 77 69 64 67 | 65 74 73 2c 20 73 75 63 | Tk widg|ets, suc|
|00000470| 68 20 61 73 20 6e 61 6d | 69 6e 67 20 63 6f 6e 76 |h as nam|ing conv|
|00000480| 65 6e 74 69 6f 6e 73 2e | 20 46 75 72 74 68 65 72 |entions.| Further|
|00000490| 6d 6f 72 65 2c 20 61 73 | 0a 65 78 70 65 63 74 65 |more, as|.expecte|
|000004a0| 64 2c 20 75 73 69 6e 67 | 20 6f 66 20 6f 62 6a 65 |d, using| of obje|
|000004b0| 63 74 73 20 66 61 63 69 | 6c 69 74 61 74 65 73 20 |cts faci|litates |
|000004c0| 63 6f 64 65 20 72 65 75 | 73 65 20 61 6e 64 20 64 |code reu|se and d|
|000004d0| 65 66 69 6e 69 74 69 6f | 6e 0a 6f 66 20 6e 65 77 |efinitio|n.of new|
|000004e0| 20 77 69 64 67 65 74 73 | 20 63 6c 61 73 73 65 73 | widgets| classes|
|000004f0| 2e 0a 0a 54 68 65 20 70 | 75 72 70 6f 73 65 20 6f |...The p|urpose o|
|00000500| 66 20 74 68 69 73 20 61 | 70 70 65 6e 64 69 78 20 |f this a|ppendix |
|00000510| 69 73 20 74 6f 20 69 6e | 74 72 6f 64 75 63 65 20 |is to in|troduce |
|00000520| 62 72 69 65 66 6c 79 20 | 74 68 65 20 7b 5c 73 74 |briefly |the {\st|
|00000530| 6b 6c 6f 73 7d 0a 70 61 | 63 6b 61 67 65 20 61 6e |klos}.pa|ckage an|
|00000540| 64 20 69 6e 20 6e 6f 20 | 63 61 73 65 20 77 69 6c |d in no |case wil|
|00000550| 6c 20 69 74 20 72 65 70 | 6c 61 63 65 20 74 68 65 |l it rep|lace the|
|00000560| 20 7b 5c 73 74 6b 6c 6f | 73 7d 20 72 65 66 65 72 | {\stklo|s} refer|
|00000570| 65 6e 63 65 20 6d 61 6e | 75 61 6c 20 28 77 68 69 |ence man|ual (whi|
|00000580| 63 68 0a 6e 65 65 64 73 | 20 74 6f 20 62 65 20 75 |ch.needs| to be u|
|00000590| 72 67 65 6e 74 6c 79 20 | 77 72 69 74 74 65 6e 20 |rgently |written |
|000005a0| 6e 6f 77 7e 5c 6c 64 6f | 74 73 29 2e 0a 49 6e 20 |now~\ldo|ts)..In |
|000005b0| 70 61 72 74 69 63 75 6c | 61 72 2c 20 6d 65 74 68 |particul|ar, meth|
|000005c0| 6f 64 73 20 72 65 6c 61 | 74 69 76 65 20 74 6f 20 |ods rela|tive to |
|000005d0| 74 68 65 20 6d 65 74 61 | 20 6f 62 6a 65 63 74 0a |the meta| object.|
|000005e0| 70 72 6f 74 6f 63 6f 6c | 20 61 6e 64 20 61 63 63 |protocol| and acc|
|000005f0| 65 73 73 20 74 6f 20 74 | 68 65 20 54 6b 20 74 6f |ess to t|he Tk to|
|00000600| 6f 6c 6b 69 74 20 77 69 | 6c 6c 20 6e 6f 74 20 62 |olkit wi|ll not b|
|00000610| 65 20 64 65 73 63 72 69 | 62 65 64 20 68 65 72 65 |e descri|bed here|
|00000620| 2e 0a 0a 5c 73 65 63 74 | 69 6f 6e 7b 43 6c 61 73 |...\sect|ion{Clas|
|00000630| 73 20 64 65 66 69 6e 69 | 74 69 6f 6e 20 61 6e 64 |s defini|tion and|
|00000640| 20 69 6e 73 74 61 6e 74 | 69 61 74 69 6f 6e 7d 0a | instant|iation}.|
|00000650| 0a 5c 73 75 62 73 65 63 | 74 69 6f 6e 20 7b 43 6c |.\subsec|tion {Cl|
|00000660| 61 73 73 20 64 65 66 69 | 6e 69 74 69 6f 6e 7d 0a |ass defi|nition}.|
|00000670| 0a 41 20 6e 65 77 20 63 | 6c 61 73 73 5c 6d 61 69 |.A new c|lass\mai|
|00000680| 6e 69 6e 64 65 78 7b 63 | 6c 61 73 73 7d 20 69 73 |nindex{c|lass} is|
|00000690| 20 64 65 66 69 6e 65 64 | 20 77 69 74 68 20 74 68 | defined| with th|
|000006a0| 65 20 7b 5c 74 74 0a 64 | 65 66 69 6e 65 2d 63 6c |e {\tt.d|efine-cl|
|000006b0| 61 73 73 7d 7b 5c 73 63 | 68 69 6e 64 65 78 7b 64 |ass}{\sc|hindex{d|
|000006c0| 65 66 69 6e 65 2d 63 6c | 61 73 73 7d 20 6d 61 63 |efine-cl|ass} mac|
|000006d0| 72 6f 2e 20 54 68 65 20 | 73 79 6e 74 61 78 20 6f |ro. The |syntax o|
|000006e0| 66 20 7b 5c 74 74 20 64 | 65 66 69 6e 65 2d 63 6c |f {\tt d|efine-cl|
|000006f0| 61 73 73 7d 0a 69 73 20 | 63 6c 6f 73 65 20 74 6f |ass}.is |close to|
|00000700| 20 43 4c 4f 53 20 7b 5c | 74 74 20 64 65 66 63 6c | CLOS {\|tt defcl|
|00000710| 61 73 73 7d 3a 0a 0a 5c | 62 65 67 69 6e 7b 73 63 |ass}:..\|begin{sc|
|00000720| 68 65 6d 65 7d 0a 28 64 | 65 66 69 6e 65 2d 63 6c |heme}.(d|efine-cl|
|00000730| 61 73 73 20 5c 76 61 72 | 7b 63 6c 61 73 73 7d 20 |ass \var|{class} |
|00000740| 28 5c 68 79 70 65 72 69 | 7b 73 75 70 65 72 63 6c |(\hyperi|{supercl|
|00000750| 61 73 73 7d 20 5c 68 79 | 70 65 72 69 69 7b 73 75 |ass} \hy|perii{su|
|00000760| 70 65 72 63 6c 61 73 73 | 7d 2e 2e 2e 29 0a 20 20 |perclass|}...). |
|00000770| 20 28 5c 68 79 70 65 72 | 69 7b 73 6c 6f 74 20 64 | (\hyper|i{slot d|
|00000780| 65 73 63 72 69 70 74 69 | 6f 6e 7d 20 5c 68 79 70 |escripti|on} \hyp|
|00000790| 65 72 69 69 7b 73 6c 6f | 74 20 64 65 73 63 72 69 |erii{slo|t descri|
|000007a0| 70 74 69 6f 6e 7d 2e 2e | 2e 29 0a 20 20 20 5c 68 |ption}..|.). \h|
|000007b0| 79 70 65 72 7b 6d 65 74 | 61 63 6c 61 73 73 20 6f |yper{met|aclass o|
|000007c0| 70 74 69 6f 6e 7d 29 0a | 5c 65 6e 64 7b 73 63 68 |ption}).|\end{sch|
|000007d0| 65 6d 65 7d 0a 0a 0a 54 | 68 65 20 5c 68 79 70 65 |eme}...T|he \hype|
|000007e0| 72 7b 6d 65 74 61 63 6c | 61 73 73 20 6f 70 74 69 |r{metacl|ass opti|
|000007f0| 6f 6e 7d 20 77 69 6c 6c | 20 6e 6f 74 20 62 65 20 |on} will| not be |
|00000800| 64 69 73 63 75 73 73 65 | 64 20 69 6e 20 74 68 69 |discusse|d in thi|
|00000810| 73 20 61 70 70 65 6e 64 | 69 78 2e 0a 54 68 65 20 |s append|ix..The |
|00000820| 5c 68 79 70 65 72 7b 73 | 75 70 65 72 63 6c 61 73 |\hyper{s|uperclas|
|00000830| 73 7d 65 73 20 6c 69 73 | 74 20 73 70 65 63 69 66 |s}es lis|t specif|
|00000840| 69 65 73 20 74 68 65 20 | 73 75 70 65 72 20 63 6c |ies the |super cl|
|00000850| 61 73 73 65 73 20 6f 66 | 20 5c 76 61 72 7b 63 6c |asses of| \var{cl|
|00000860| 61 73 73 7d 20 28 73 65 | 65 20 0a 5c 72 65 66 7b |ass} (se|e .\ref{|
|00000870| 69 6e 68 65 72 69 74 61 | 6e 63 65 7d 20 66 6f 72 |inherita|nce} for|
|00000880| 20 6d 6f 72 65 20 64 65 | 74 61 69 6c 73 29 2e 20 | more de|tails). |
|00000890| 0a 41 20 5c 68 79 70 65 | 72 7b 73 6c 6f 74 20 64 |.A \hype|r{slot d|
|000008a0| 65 73 63 72 69 70 74 69 | 6f 6e 7d 20 67 69 76 65 |escripti|on} give|
|000008b0| 73 20 74 68 65 20 6e 61 | 6d 65 20 6f 66 20 61 20 |s the na|me of a |
|000008c0| 73 6c 6f 74 5c 6d 61 69 | 6e 69 6e 64 65 78 7b 73 |slot\mai|nindex{s|
|000008d0| 6c 6f 74 7d 20 61 6e 64 | 2c 0a 65 76 65 6e 74 75 |lot} and|,.eventu|
|000008e0| 61 6c 6c 79 2c 20 73 6f | 6d 65 20 60 60 70 72 6f |ally, so|me ``pro|
|000008f0| 70 65 72 74 69 65 73 27 | 27 20 6f 66 20 74 68 69 |perties'|' of thi|
|00000900| 73 20 73 6c 6f 74 20 28 | 73 75 63 68 20 61 73 20 |s slot (|such as |
|00000910| 69 74 73 20 69 6e 69 74 | 69 61 6c 20 76 61 6c 75 |its init|ial valu|
|00000920| 65 2c 20 74 68 65 0a 66 | 75 6e 63 74 69 6f 6e 20 |e, the.f|unction |
|00000930| 77 68 69 63 68 20 70 65 | 72 6d 69 74 20 74 6f 20 |which pe|rmit to |
|00000940| 61 63 63 65 73 73 20 69 | 74 73 20 76 61 6c 75 65 |access i|ts value|
|00000950| 2c 20 5c 6c 64 6f 74 73 | 29 2e 20 53 6c 6f 74 20 |, \ldots|). Slot |
|00000960| 64 65 73 63 72 69 70 74 | 69 6f 6e 73 20 77 69 6c |descript|ions wil|
|00000970| 6c 20 62 65 0a 64 69 73 | 63 75 73 73 65 64 20 69 |l be.dis|cussed i|
|00000980| 6e 0a 5c 72 65 66 7b 73 | 6c 6f 74 2d 64 65 73 63 |n.\ref{s|lot-desc|
|00000990| 72 69 70 74 69 6f 6e 7d | 2e 0a 0a 41 73 20 61 6e |ription}|...As an|
|000009a0| 20 65 78 65 6d 70 6c 65 | 2c 20 63 6f 6e 73 69 64 | exemple|, consid|
|000009b0| 65 72 20 6e 6f 77 20 74 | 68 61 74 20 77 65 20 68 |er now t|hat we h|
|000009c0| 61 76 65 20 74 6f 20 64 | 65 66 69 6e 65 20 61 20 |ave to d|efine a |
|000009d0| 63 6f 6d 70 6c 65 78 20 | 6e 75 6d 62 65 72 2e 20 |complex |number. |
|000009e0| 54 68 69 73 20 63 61 6e | 0a 62 65 20 64 6f 6e 65 |This can|.be done|
|000009f0| 20 77 69 74 68 20 74 68 | 65 20 66 6f 6c 6c 6f 77 | with th|e follow|
|00000a00| 69 6e 67 20 63 6c 61 73 | 73 20 64 65 66 69 6e 69 |ing clas|s defini|
|00000a10| 74 69 6f 6e 3a 0a 0a 5c | 62 65 67 69 6e 7b 73 63 |tion:..\|begin{sc|
|00000a20| 68 65 6d 65 7d 0a 28 64 | 65 66 69 6e 65 2d 63 6c |heme}.(d|efine-cl|
|00000a30| 61 73 73 20 20 3c 63 6f | 6d 70 6c 65 78 3e 20 28 |ass <co|mplex> (|
|00000a40| 3c 6e 75 6d 62 65 72 3e | 29 0a 20 20 20 28 72 20 |<number>|). (r |
|00000a50| 69 29 29 0a 5c 65 6e 64 | 7b 73 63 68 65 6d 65 7d |i)).\end|{scheme}|
|00000a60| 0a 0a 54 68 69 73 20 62 | 69 6e 64 73 20 74 68 65 |..This b|inds the|
|00000a70| 20 73 79 6d 62 6f 6c 20 | 7b 5c 74 74 20 3c 63 6f | symbol |{\tt <co|
|00000a80| 6d 70 6c 65 78 3e 7d 20 | 74 6f 20 61 20 6e 65 77 |mplex>} |to a new|
|00000a90| 20 63 6c 61 73 73 20 77 | 68 6f 73 65 20 69 6e 73 | class w|hose ins|
|00000aa0| 74 61 6e 63 65 73 20 63 | 6f 6e 74 61 69 6e 0a 74 |tances c|ontain.t|
|00000ab0| 77 6f 20 73 6c 6f 74 73 | 2e 20 54 68 65 73 65 20 |wo slots|. These |
|00000ac0| 73 6c 6f 74 73 20 61 72 | 65 20 63 61 6c 6c 65 64 |slots ar|e called|
|00000ad0| 20 7b 5c 74 74 20 72 7d | 20 61 6e 20 7b 5c 74 74 | {\tt r}| an {\tt|
|00000ae0| 20 69 7d 20 61 6e 64 20 | 77 65 20 73 75 70 70 6f | i} and |we suppo|
|00000af0| 73 65 20 68 65 72 65 0a | 74 68 61 74 20 74 68 65 |se here.|that the|
|00000b00| 79 20 63 6f 6e 74 61 69 | 6e 20 72 65 73 70 65 63 |y contai|n respec|
|00000b10| 74 69 76 65 6c 79 20 74 | 68 65 20 72 65 61 6c 20 |tively t|he real |
|00000b20| 70 61 72 74 20 61 6e 64 | 20 74 68 65 20 69 6d 61 |part and| the ima|
|00000b30| 67 69 6e 61 72 79 20 70 | 61 72 74 20 6f 66 20 61 |ginary p|art of a|
|00000b40| 0a 63 6f 6d 70 6c 65 78 | 20 6e 75 6d 62 65 72 2e |.complex| number.|
|00000b50| 20 4e 6f 74 65 20 74 68 | 61 74 20 74 68 69 73 20 | Note th|at this |
|00000b60| 63 6c 61 73 73 20 69 6e | 68 65 72 69 74 73 20 66 |class in|herits f|
|00000b70| 72 6f 6d 20 7b 5c 74 74 | 20 3c 6e 75 6d 62 65 72 |rom {\tt| <number|
|00000b80| 3e 7d 20 77 68 69 63 68 | 20 69 73 20 61 0a 70 72 |>} which| is a.pr|
|00000b90| 65 2d 64 65 66 69 6e 65 | 64 20 63 6c 61 73 73 20 |e-define|d class |
|00000ba0| 28 7b 5c 74 74 20 3c 6e | 75 6d 62 65 72 3e 7d 20 |({\tt <n|umber>} |
|00000bb0| 69 73 20 74 68 65 20 73 | 75 70 65 72 20 63 6c 61 |is the s|uper cla|
|00000bc0| 73 73 20 6f 66 20 74 68 | 65 20 7b 5c 74 74 20 3c |ss of th|e {\tt <|
|00000bd0| 72 65 61 6c 3e 7d 20 61 | 6e 64 0a 7b 5c 74 74 20 |real>} a|nd.{\tt |
|00000be0| 3c 69 6e 74 65 67 65 72 | 3e 7d 20 70 72 65 2d 64 |<integer|>} pre-d|
|00000bf0| 65 66 69 6e 65 64 20 63 | 6c 61 73 73 65 73 29 2e |efined c|lasses).|
|00000c00| 5c 66 6f 6f 74 6e 6f 74 | 65 7b 57 69 74 68 20 74 |\footnot|e{With t|
|00000c10| 68 69 73 20 64 65 66 69 | 6e 69 74 69 6f 6e 2c 20 |his defi|nition, |
|00000c20| 61 20 7b 5c 74 74 0a 3c | 72 65 61 6c 3e 7d 20 69 |a {\tt.<|real>} i|
|00000c30| 73 20 6e 6f 74 20 61 20 | 7b 5c 74 74 20 3c 63 6f |s not a |{\tt <co|
|00000c40| 6d 70 6c 65 78 3e 7d 20 | 73 69 6e 63 65 20 7b 5c |mplex>} |since {\|
|00000c50| 74 74 20 3c 72 65 61 6c | 3e 7d 20 69 6e 68 65 72 |tt <real|>} inher|
|00000c60| 69 74 73 20 66 72 6f 6d | 20 7b 5c 74 74 0a 3c 6e |its from| {\tt.<n|
|00000c70| 75 6d 62 65 72 3e 7d 20 | 72 61 74 68 65 72 20 74 |umber>} |rather t|
|00000c80| 68 61 6e 20 7b 5c 74 74 | 20 3c 63 6f 6d 70 6c 65 |han {\tt| <comple|
|00000c90| 78 3e 7d 2e 20 49 6e 20 | 70 72 61 63 74 69 63 65 |x>}. In |practice|
|00000ca0| 2c 20 69 6e 68 65 72 69 | 74 61 6e 63 65 20 63 6f |, inheri|tance co|
|00000cb0| 75 6c 64 20 62 65 0a 6d | 6f 64 69 66 69 65 64 20 |uld be.m|odified |
|00000cc0| 7b 5c 65 6d 20 61 20 70 | 6f 73 74 65 72 69 6f 72 |{\em a p|osterior|
|00000cd0| 69 7d 2c 20 69 66 20 6e | 65 65 64 65 64 2e 20 48 |i}, if n|eeded. H|
|00000ce0| 6f 77 65 76 65 72 2c 20 | 74 68 69 73 20 6e 65 63 |owever, |this nec|
|00000cf0| 65 73 73 69 74 61 74 65 | 73 20 73 6f 6d 65 0a 6b |essitate|s some.k|
|00000d00| 6e 6f 77 6c 65 64 67 65 | 20 6f 66 20 74 68 65 20 |nowledge| of the |
|00000d10| 6d 65 74 61 20 6f 62 6a | 65 63 74 20 70 72 6f 74 |meta obj|ect prot|
|00000d20| 6f 63 6f 6c 20 61 6e 64 | 20 69 74 20 77 69 6c 6c |ocol and| it will|
|00000d30| 20 6e 6f 74 20 62 65 20 | 73 68 6f 77 6e 20 69 6e | not be |shown in|
|00000d40| 20 74 68 69 73 0a 64 6f | 63 75 6d 65 6e 74 7d 2e | this.do|cument}.|
|00000d50| 0a 0a 5c 73 65 63 74 69 | 6f 6e 7b 49 6e 68 65 72 |..\secti|on{Inher|
|00000d60| 69 74 61 6e 63 65 7d 0a | 5c 6c 61 62 65 6c 7b 69 |itance}.|\label{i|
|00000d70| 6e 68 65 72 69 74 61 6e | 63 65 7d 0a 5c 73 75 62 |nheritan|ce}.\sub|
|00000d80| 73 65 63 74 69 6f 6e 7b | 43 6c 61 73 73 20 68 69 |section{|Class hi|
|00000d90| 65 72 61 72 63 68 79 20 | 61 6e 64 20 69 6e 68 65 |erarchy |and inhe|
|00000da0| 72 69 74 61 6e 63 65 20 | 6f 66 20 73 6c 6f 74 73 |ritance |of slots|
|00000db0| 7d 0a 49 6e 68 65 72 69 | 74 61 6e 63 65 20 69 73 |}.Inheri|tance is|
|00000dc0| 20 73 70 65 63 69 66 69 | 65 64 20 75 70 6f 6e 20 | specifi|ed upon |
|00000dd0| 63 6c 61 73 73 0a 64 65 | 66 69 6e 69 74 69 6f 6e |class.de|finition|
|00000de0| 2e 20 41 73 20 73 61 69 | 64 20 69 6e 20 74 68 65 |. As sai|d in the|
|00000df0| 20 69 6e 74 72 6f 64 75 | 63 74 69 6f 6e 2c 20 7b | introdu|ction, {|
|00000e00| 5c 73 74 6b 6c 6f 73 7d | 20 73 75 70 70 6f 72 74 |\stklos}| support|
|00000e10| 73 20 6d 75 6c 74 69 70 | 6c 65 20 69 6e 68 65 72 |s multip|le inher|
|00000e20| 69 74 61 6e 63 65 2e 20 | 0a 48 65 72 65 61 66 74 |itance. |.Hereaft|
|00000e30| 65 72 20 61 72 65 20 73 | 6f 6d 65 20 63 6c 61 73 |er are s|ome clas|
|00000e40| 73 65 73 20 64 65 66 69 | 6e 69 74 69 6f 6e 3a 20 |ses defi|nition: |
|00000e50| 0a 5c 62 65 67 69 6e 7b | 73 63 68 65 6d 65 7d 0a |.\begin{|scheme}.|
|00000e60| 28 64 65 66 69 6e 65 2d | 63 6c 61 73 73 20 41 20 |(define-|class A |
|00000e70| 28 29 20 28 61 29 29 0a | 28 64 65 66 69 6e 65 2d |() (a)).|(define-|
|00000e80| 63 6c 61 73 73 20 42 20 | 28 29 20 28 62 29 29 0a |class B |() (b)).|
|00000e90| 28 64 65 66 69 6e 65 2d | 63 6c 61 73 73 20 43 20 |(define-|class C |
|00000ea0| 28 29 20 28 63 29 29 0a | 28 64 65 66 69 6e 65 2d |() (c)).|(define-|
|00000eb0| 63 6c 61 73 73 20 44 20 | 28 41 20 42 29 20 28 64 |class D |(A B) (d|
|00000ec0| 20 61 29 29 0a 28 64 65 | 66 69 6e 65 2d 63 6c 61 | a)).(de|fine-cla|
|00000ed0| 73 73 20 45 20 28 41 20 | 43 29 20 28 65 20 63 29 |ss E (A |C) (e c)|
|00000ee0| 29 0a 28 64 65 66 69 6e | 65 2d 63 6c 61 73 73 20 |).(defin|e-class |
|00000ef0| 46 20 28 44 20 45 29 20 | 28 66 29 29 0a 5c 65 6e |F (D E) |(f)).\en|
|00000f00| 64 7b 73 63 68 65 6d 65 | 7d 0a 0a 7b 5c 74 74 20 |d{scheme|}..{\tt |
|00000f10| 41 7d 2c 20 7b 5c 74 74 | 20 42 7d 2c 20 7b 5c 74 |A}, {\tt| B}, {\t|
|00000f20| 74 20 43 7d 20 68 61 76 | 65 20 61 20 6e 75 6c 6c |t C} hav|e a null|
|00000f30| 20 6c 69 73 74 20 6f 66 | 20 73 75 70 65 72 20 63 | list of| super c|
|00000f40| 6c 61 73 73 65 73 2e 20 | 49 6e 20 74 68 69 73 20 |lasses. |In this |
|00000f50| 63 61 73 65 2c 20 74 68 | 65 0a 73 79 73 74 65 6d |case, th|e.system|
|00000f60| 20 77 69 6c 6c 20 72 65 | 70 6c 61 63 65 20 69 74 | will re|place it|
|00000f70| 20 62 79 20 74 68 65 20 | 6c 69 73 74 20 77 68 69 | by the |list whi|
|00000f80| 63 68 20 6f 6e 6c 79 20 | 63 6f 6e 74 61 69 6e 73 |ch only |contains|
|00000f90| 20 5c 69 64 65 7b 3c 6f | 62 6a 65 63 74 3e 7d 2c | \ide{<o|bject>},|
|00000fa0| 20 74 68 65 0a 72 6f 6f | 74 20 6f 66 20 61 6c 6c | the.roo|t of all|
|00000fb0| 20 74 68 65 20 63 6c 61 | 73 73 65 73 20 64 65 66 | the cla|sses def|
|00000fc0| 69 6e 65 64 20 62 79 20 | 5c 69 64 65 7b 64 65 66 |ined by |\ide{def|
|00000fd0| 69 6e 65 2d 63 6c 61 73 | 73 7d 2e 20 7b 5c 74 74 |ine-clas|s}. {\tt|
|00000fe0| 20 44 7d 2c 20 7b 5c 74 | 74 20 45 7d 2c 20 7b 5c | D}, {\t|t E}, {\|
|00000ff0| 74 74 0a 46 7d 20 75 73 | 65 20 6d 75 6c 74 69 70 |tt.F} us|e multip|
|00001000| 6c 65 20 69 6e 68 65 72 | 69 74 61 6e 63 65 3a 20 |le inher|itance: |
|00001010| 65 61 63 68 20 63 6c 61 | 73 73 20 69 6e 68 65 72 |each cla|ss inher|
|00001020| 69 74 73 20 66 72 6f 6d | 20 74 77 6f 20 70 72 65 |its from| two pre|
|00001030| 76 69 6f 75 73 6c 79 0a | 64 65 66 69 6e 65 64 20 |viously.|defined |
|00001040| 63 6c 61 73 73 65 73 2e | 20 20 54 68 6f 73 65 20 |classes.| Those |
|00001050| 63 6c 61 73 73 20 64 65 | 66 69 6e 69 74 69 6f 6e |class de|finition|
|00001060| 73 20 64 65 66 69 6e 65 | 20 61 20 68 69 65 72 61 |s define| a hiera|
|00001070| 72 63 68 79 20 77 68 69 | 63 68 20 69 73 0a 73 68 |rchy whi|ch is.sh|
|00001080| 6f 77 6e 20 69 6e 20 46 | 69 67 75 72 65 7e 31 2e |own in F|igure~1.|
|00001090| 20 20 49 6e 20 74 68 69 | 73 20 66 69 67 75 72 65 | In thi|s figure|
|000010a0| 2c 20 74 68 65 20 63 6c | 61 73 73 20 5c 69 64 65 |, the cl|ass \ide|
|000010b0| 7b 3c 74 6f 70 3e 7d 20 | 69 73 20 61 6c 73 6f 20 |{<top>} |is also |
|000010c0| 73 68 6f 77 6e 3b 20 74 | 68 69 73 0a 63 6c 61 73 |shown; t|his.clas|
|000010d0| 73 20 69 73 20 74 68 65 | 20 73 75 70 65 72 20 63 |s is the| super c|
|000010e0| 6c 61 73 73 20 6f 66 20 | 61 6c 6c 20 53 63 68 65 |lass of |all Sche|
|000010f0| 6d 65 20 6f 62 6a 65 63 | 74 73 2e 20 49 6e 20 70 |me objec|ts. In p|
|00001100| 61 72 74 69 63 75 6c 61 | 72 2c 0a 5c 69 64 65 7b |articula|r,.\ide{|
|00001110| 3c 74 6f 70 3e 7d 20 69 | 73 20 74 68 65 20 73 75 |<top>} i|s the su|
|00001120| 70 65 72 20 63 6c 61 73 | 73 20 6f 66 20 61 6c 6c |per clas|s of all|
|00001130| 20 73 74 61 6e 64 61 72 | 64 20 53 63 68 65 6d 65 | standar|d Scheme|
|00001140| 20 74 79 70 65 73 2e 0a | 0a 5c 62 65 67 69 6e 7b | types..|.\begin{|
|00001150| 66 69 67 75 72 65 7d 0a | 5c 63 65 6e 74 65 72 6c |figure}.|\centerl|
|00001160| 69 6e 65 7b 5c 70 73 66 | 69 67 7b 66 69 67 75 72 |ine{\psf|ig{figur|
|00001170| 65 3d 7b 68 69 65 72 61 | 72 63 68 79 2e 65 70 73 |e={hiera|rchy.eps|
|00001180| 7d 7d 7d 0a 5c 63 61 70 | 74 69 6f 6e 7b 41 20 63 |}}}.\cap|tion{A c|
|00001190| 6c 61 73 73 20 68 69 65 | 72 61 72 63 68 79 7d 0a |lass hie|rarchy}.|
|000011a0| 5c 65 6e 64 7b 66 69 67 | 75 72 65 7d 0a 0a 54 68 |\end{fig|ure}..Th|
|000011b0| 65 20 73 65 74 20 6f 66 | 20 73 6c 6f 74 73 20 6f |e set of| slots o|
|000011c0| 66 20 61 20 67 69 76 65 | 6e 20 63 6c 61 73 73 20 |f a give|n class |
|000011d0| 69 73 20 63 61 6c 63 75 | 6c 61 74 65 64 20 62 79 |is calcu|lated by|
|000011e0| 20 60 60 75 6e 69 6f 6e | 69 6e 67 27 27 20 74 68 | ``union|ing'' th|
|000011f0| 65 20 73 6c 6f 74 73 20 | 6f 66 0a 61 6c 6c 20 69 |e slots |of.all i|
|00001200| 74 73 20 73 75 70 65 72 | 20 63 6c 61 73 73 2e 20 |ts super| class. |
|00001210| 46 6f 72 20 69 6e 73 74 | 61 6e 63 65 2c 20 65 61 |For inst|ance, ea|
|00001220| 63 68 20 69 6e 73 74 61 | 6e 63 65 20 6f 66 20 74 |ch insta|nce of t|
|00001230| 68 65 20 63 6c 61 73 73 | 20 44 2c 20 64 65 66 69 |he class| D, defi|
|00001240| 6e 65 64 0a 62 65 66 6f | 72 65 20 77 69 6c 6c 20 |ned.befo|re will |
|00001250| 68 61 76 65 20 74 68 72 | 65 65 20 73 6c 6f 74 73 |have thr|ee slots|
|00001260| 20 28 7b 5c 74 74 20 61 | 7d 2c 20 7b 5c 74 74 20 | ({\tt a|}, {\tt |
|00001270| 62 7d 20 61 6e 64 20 7b | 5c 74 74 20 64 7d 29 2e |b} and {|\tt d}).|
|00001280| 20 54 68 65 20 73 6c 6f | 74 73 20 6f 66 20 61 20 | The slo|ts of a |
|00001290| 63 6c 61 73 73 20 0a 63 | 61 6e 20 62 65 20 6f 62 |class .c|an be ob|
|000012a0| 74 61 69 6e 65 64 20 62 | 79 20 74 68 65 20 5c 69 |tained b|y the \i|
|000012b0| 64 65 7b 63 6c 61 73 73 | 2d 73 6c 6f 74 73 7d 20 |de{class|-slots} |
|000012c0| 70 72 69 6d 69 74 69 76 | 65 2e 0a 46 6f 72 20 69 |primitiv|e..For i|
|000012d0| 6e 73 74 61 6e 63 65 2c | 20 0a 5c 62 65 67 69 6e |nstance,| .\begin|
|000012e0| 7b 73 63 68 65 6d 65 7d | 0a 28 63 6c 61 73 73 2d |{scheme}|.(class-|
|000012f0| 73 6c 6f 74 73 20 41 29 | 20 5c 6c 65 76 20 28 61 |slots A)| \lev (a|
|00001300| 29 0a 28 63 6c 61 73 73 | 2d 73 6c 6f 74 73 20 45 |).(class|-slots E|
|00001310| 29 20 5c 6c 65 76 20 28 | 61 20 65 20 63 29 0a 28 |) \lev (|a e c).(|
|00001320| 63 6c 61 73 73 2d 73 6c | 6f 74 73 20 46 29 20 5c |class-sl|ots F) \|
|00001330| 6c 65 76 20 28 64 20 61 | 20 62 20 63 20 66 29 0a |lev (d a| b c f).|
|00001340| 5c 65 6e 64 7b 73 63 68 | 65 6d 65 7d 0a 0a 5c 62 |\end{sch|eme}..\b|
|00001350| 65 67 69 6e 7b 6e 6f 74 | 65 7d 0a 54 68 65 20 6f |egin{not|e}.The o|
|00001360| 72 64 65 72 20 6f 66 20 | 73 6c 6f 74 73 20 69 73 |rder of |slots is|
|00001370| 20 6e 6f 74 20 73 69 67 | 6e 69 66 69 63 61 6e 74 | not sig|nificant|
|00001380| 2e 0a 5c 65 6e 64 7b 6e | 6f 74 65 7d 0a 0a 5c 73 |..\end{n|ote}..\s|
|00001390| 75 62 73 65 63 74 69 6f | 6e 20 7b 49 6e 73 74 61 |ubsectio|n {Insta|
|000013a0| 6e 63 65 20 63 72 65 61 | 74 69 6f 6e 20 61 6e 64 |nce crea|tion and|
|000013b0| 20 73 6c 6f 74 20 61 63 | 63 65 73 73 7d 0a 0a 43 | slot ac|cess}..C|
|000013c0| 72 65 61 74 69 6f 6e 20 | 6f 66 20 61 6e 20 69 6e |reation |of an in|
|000013d0| 73 74 61 6e 63 65 5c 6d | 61 69 6e 69 6e 64 65 78 |stance\m|ainindex|
|000013e0| 7b 69 6e 73 74 61 6e 63 | 65 7d 20 6f 66 20 61 20 |{instanc|e} of a |
|000013f0| 70 72 65 76 69 6f 75 73 | 6c 79 20 64 65 66 69 6e |previous|ly defin|
|00001400| 65 64 0a 63 6c 61 73 73 | 20 63 61 6e 20 62 65 20 |ed.class| can be |
|00001410| 64 6f 6e 65 20 77 69 74 | 68 20 74 68 65 20 7b 5c |done wit|h the {\|
|00001420| 74 74 20 6d 61 6b 65 7d | 5c 73 63 68 69 6e 64 65 |tt make}|\schinde|
|00001430| 78 7b 6d 61 6b 65 7d 20 | 70 72 6f 63 65 64 75 72 |x{make} |procedur|
|00001440| 65 2e 20 54 68 69 73 0a | 70 72 6f 63 65 64 75 72 |e. This.|procedur|
|00001450| 65 20 74 61 6b 65 73 20 | 6f 6e 65 20 6d 61 6e 64 |e takes |one mand|
|00001460| 61 74 6f 72 79 20 70 61 | 72 61 6d 65 74 65 72 20 |atory pa|rameter |
|00001470| 77 68 69 63 68 20 69 73 | 20 74 68 65 20 63 6c 61 |which is| the cla|
|00001480| 73 73 20 6f 66 20 74 68 | 65 0a 69 6e 73 74 61 6e |ss of th|e.instan|
|00001490| 63 65 20 77 68 69 63 68 | 20 6d 75 73 74 20 62 65 |ce which| must be|
|000014a0| 20 63 72 65 61 74 65 64 | 20 61 6e 64 20 61 20 6c | created| and a l|
|000014b0| 69 73 74 20 6f 66 20 6f | 70 74 69 6f 6e 61 6c 0a |ist of o|ptional.|
|000014c0| 61 72 67 75 6d 65 6e 74 | 73 2e 20 4f 70 74 69 6f |argument|s. Optio|
|000014d0| 6e 61 6c 20 61 72 67 75 | 6d 65 6e 74 73 20 61 72 |nal argu|ments ar|
|000014e0| 65 20 67 65 6e 65 72 61 | 6c 6c 79 20 75 73 65 64 |e genera|lly used|
|000014f0| 20 74 6f 20 69 6e 69 74 | 69 61 6c 69 7a 65 20 73 | to init|ialize s|
|00001500| 6f 6d 65 0a 73 6c 6f 74 | 73 20 6f 66 20 74 68 65 |ome.slot|s of the|
|00001510| 20 6e 65 77 6c 79 20 63 | 72 65 61 74 65 64 20 69 | newly c|reated i|
|00001520| 6e 73 74 61 6e 63 65 2e | 20 46 6f 72 20 69 6e 73 |nstance.| For ins|
|00001530| 74 61 6e 63 65 2c 20 74 | 68 65 20 66 6f 6c 6c 6f |tance, t|he follo|
|00001540| 77 69 6e 67 20 66 6f 72 | 6d 0a 0a 5c 62 65 67 69 |wing for|m..\begi|
|00001550| 6e 7b 73 63 68 65 6d 65 | 7d 0a 28 64 65 66 69 6e |n{scheme|}.(defin|
|00001560| 65 20 63 20 28 6d 61 6b | 65 20 3c 63 6f 6d 70 6c |e c (mak|e <compl|
|00001570| 65 78 3e 29 29 0a 5c 65 | 6e 64 7b 73 63 68 65 6d |ex>)).\e|nd{schem|
|00001580| 65 7d 0a 0a 77 69 6c 6c | 20 63 72 65 61 74 65 20 |e}..will| create |
|00001590| 61 20 6e 65 77 20 7b 5c | 74 74 20 3c 63 6f 6d 70 |a new {\|tt <comp|
|000015a0| 6c 65 78 3e 7d 20 6f 62 | 6a 65 63 74 20 61 6e 64 |lex>} ob|ject and|
|000015b0| 20 77 69 6c 6c 20 62 69 | 6e 64 20 69 74 20 74 6f | will bi|nd it to|
|000015c0| 20 74 68 65 20 7b 5c 74 | 74 20 63 7d 0a 53 63 68 | the {\t|t c}.Sch|
|000015d0| 65 6d 65 20 76 61 72 69 | 61 62 6c 65 2e 0a 0a 41 |eme vari|able...A|
|000015e0| 63 63 65 73 73 69 6e 67 | 20 74 68 65 20 73 6c 6f |ccessing| the slo|
|000015f0| 74 73 20 6f 66 20 74 68 | 65 20 6e 65 77 20 63 6f |ts of th|e new co|
|00001600| 6d 70 6c 65 78 20 6e 75 | 6d 62 65 72 20 63 61 6e |mplex nu|mber can|
|00001610| 20 62 65 20 64 6f 6e 65 | 20 77 69 74 68 20 74 68 | be done| with th|
|00001620| 65 20 7b 5c 74 74 0a 73 | 6c 6f 74 2d 72 65 66 7d |e {\tt.s|lot-ref}|
|00001630| 5c 73 63 68 69 6e 64 65 | 78 7b 73 6c 6f 74 2d 72 |\schinde|x{slot-r|
|00001640| 65 66 7d 20 61 6e 64 20 | 74 68 65 20 7b 5c 74 74 |ef} and |the {\tt|
|00001650| 20 73 6c 6f 74 2d 73 65 | 74 21 7d 5c 73 63 68 69 | slot-se|t!}\schi|
|00001660| 6e 64 65 78 7b 73 6c 6f | 74 2d 73 65 74 21 7d 0a |ndex{slo|t-set!}.|
|00001670| 70 72 69 6d 69 74 69 76 | 65 73 2e 20 7b 5c 74 74 |primitiv|es. {\tt|
|00001680| 20 53 6c 6f 74 2d 73 65 | 74 21 7d 20 70 72 69 6d | Slot-se|t!} prim|
|00001690| 69 74 69 76 65 20 70 65 | 72 6d 69 74 73 20 74 6f |itive pe|rmits to|
|000016a0| 20 73 65 74 20 74 68 65 | 20 76 61 6c 75 65 20 6f | set the| value o|
|000016b0| 66 20 61 6e 20 6f 62 6a | 65 63 74 0a 73 6c 6f 74 |f an obj|ect.slot|
|000016c0| 20 61 6e 64 20 7b 5c 74 | 74 20 73 6c 6f 74 2d 72 | and {\t|t slot-r|
|000016d0| 65 66 7d 20 70 65 72 6d | 69 74 73 20 74 6f 20 67 |ef} perm|its to g|
|000016e0| 65 74 20 69 74 73 20 76 | 61 6c 75 65 2e 0a 0a 5c |et its v|alue...\|
|000016f0| 62 65 67 69 6e 7b 73 63 | 68 65 6d 65 7d 0a 28 73 |begin{sc|heme}.(s|
|00001700| 6c 6f 74 2d 73 65 74 21 | 20 63 20 27 72 20 31 30 |lot-set!| c 'r 10|
|00001710| 29 0a 28 73 6c 6f 74 2d | 73 65 74 21 20 63 20 27 |).(slot-|set! c '|
|00001720| 69 20 33 29 0a 28 73 6c | 6f 74 2d 72 65 66 20 63 |i 3).(sl|ot-ref c|
|00001730| 20 27 72 29 20 5c 6c 65 | 76 20 31 30 0a 28 73 6c | 'r) \le|v 10.(sl|
|00001740| 6f 74 2d 72 65 66 20 63 | 20 27 69 29 20 5c 6c 65 |ot-ref c| 'i) \le|
|00001750| 76 20 33 0a 5c 65 6e 64 | 7b 73 63 68 65 6d 65 7d |v 3.\end|{scheme}|
|00001760| 0a 0a 55 73 69 6e 67 20 | 74 68 65 20 5c 69 64 65 |..Using |the \ide|
|00001770| 7b 64 65 73 63 72 69 62 | 65 7d 20 67 65 6e 65 72 |{describ|e} gener|
|00001780| 69 63 20 66 75 6e 63 74 | 69 6f 6e 20 69 73 20 61 |ic funct|ion is a|
|00001790| 20 73 69 6d 70 6c 65 20 | 77 61 79 20 74 6f 20 73 | simple |way to s|
|000017a0| 65 65 20 61 6c 6c 0a 74 | 68 65 20 73 6c 6f 74 73 |ee all.t|he slots|
|000017b0| 20 6f 66 20 61 6e 20 6f | 62 6a 65 63 74 20 61 74 | of an o|bject at|
|000017c0| 20 6f 6e 65 20 74 69 6d | 65 3a 20 74 68 69 73 20 | one tim|e: this |
|000017d0| 66 75 6e 63 74 69 6f 6e | 20 70 72 69 6e 74 73 20 |function| prints |
|000017e0| 61 6c 6c 20 74 68 65 20 | 73 6c 6f 74 73 0a 6f 66 |all the |slots.of|
|000017f0| 20 61 6e 20 6f 62 6a 65 | 63 74 20 6f 6e 20 74 68 | an obje|ct on th|
|00001800| 65 20 73 74 61 6e 64 61 | 72 64 20 6f 75 74 70 75 |e standa|rd outpu|
|00001810| 74 2e 20 46 6f 72 20 69 | 6e 73 74 61 6e 63 65 2c |t. For i|nstance,|
|00001820| 20 74 68 65 20 65 78 70 | 72 65 73 73 69 6f 6e 0a | the exp|ression.|
|00001830| 0a 5c 62 65 67 69 6e 7b | 73 63 68 65 6d 65 7d 0a |.\begin{|scheme}.|
|00001840| 28 64 65 73 63 72 69 62 | 65 20 63 29 0a 5c 65 6e |(describ|e c).\en|
|00001850| 64 7b 73 63 68 65 6d 65 | 7d 0a 77 69 6c 6c 20 70 |d{scheme|}.will p|
|00001860| 72 69 6e 74 20 74 68 65 | 20 66 6f 6c 6c 6f 77 69 |rint the| followi|
|00001870| 6e 67 20 69 6e 66 6f 72 | 6d 61 74 69 6f 6e 73 20 |ng infor|mations |
|00001880| 6f 6e 20 74 68 65 20 73 | 74 61 6e 64 61 72 64 20 |on the s|tandard |
|00001890| 6f 75 74 70 75 74 3a 0a | 5c 62 65 67 69 6e 7b 73 |output:.|\begin{s|
|000018a0| 63 68 65 6d 65 7d 0a 5c | 73 68 61 72 70 73 69 67 |cheme}.\|sharpsig|
|000018b0| 6e 5b 3c 63 6f 6d 70 6c | 65 78 3e 20 31 32 32 33 |n[<compl|ex> 1223|
|000018c0| 39 38 5d 20 69 73 20 61 | 6e 20 69 6e 73 74 61 6e |98] is a|n instan|
|000018d0| 63 65 20 6f 66 20 63 6c | 61 73 73 20 3c 63 6f 6d |ce of cl|ass <com|
|000018e0| 70 6c 65 78 3e 0a 53 6c | 6f 74 73 20 61 72 65 3a |plex>.Sl|ots are:|
|000018f0| 20 0a 20 20 20 20 20 72 | 20 3d 20 31 30 0a 20 20 | . r| = 10. |
|00001900| 20 20 20 69 20 3d 20 33 | 0a 5c 65 6e 64 7b 73 63 | i = 3|.\end{sc|
|00001910| 68 65 6d 65 7d 0a 0a 5c | 73 75 62 73 65 63 74 69 |heme}..\|subsecti|
|00001920| 6f 6e 7b 53 6c 6f 74 20 | 64 65 73 63 72 69 70 74 |on{Slot |descript|
|00001930| 69 6f 6e 7d 0a 5c 6c 61 | 62 65 6c 7b 73 6c 6f 74 |ion}.\la|bel{slot|
|00001940| 2d 64 65 73 63 72 69 70 | 74 69 6f 6e 7d 0a 0a 57 |-descrip|tion}..W|
|00001950| 68 65 6e 20 73 70 65 63 | 69 66 79 69 6e 67 20 61 |hen spec|ifying a|
|00001960| 20 73 6c 6f 74 2c 20 61 | 20 73 65 74 20 6f 66 20 | slot, a| set of |
|00001970| 6f 70 74 69 6f 6e 73 20 | 63 61 6e 20 62 65 20 67 |options |can be g|
|00001980| 69 76 65 6e 20 74 6f 20 | 74 68 65 20 73 79 73 74 |iven to |the syst|
|00001990| 65 6d 2e 20 45 61 63 68 | 20 6f 70 74 69 6f 6e 20 |em. Each| option |
|000019a0| 0a 69 73 20 73 70 65 63 | 69 66 69 65 64 20 77 69 |.is spec|ified wi|
|000019b0| 74 68 20 61 20 6b 65 79 | 77 6f 72 64 7b 5c 6d 61 |th a key|word{\ma|
|000019c0| 69 6e 69 6e 64 65 78 7b | 6b 65 79 77 6f 72 64 7d |inindex{|keyword}|
|000019d0| 7d 2e 20 54 68 65 20 6c | 69 73 74 20 6f 66 20 61 |}. The l|ist of a|
|000019e0| 75 74 68 6f 72 69 73 65 | 64 20 6b 65 79 77 6f 72 |uthorise|d keywor|
|000019f0| 64 73 20 69 73 20 0a 67 | 69 76 65 6e 20 62 65 6c |ds is .g|iven bel|
|00001a00| 6f 77 3a 0a 5c 62 65 67 | 69 6e 7b 69 74 65 6d 69 |ow:.\beg|in{itemi|
|00001a10| 7a 65 7d 0a 0a 5c 69 74 | 65 6d 20 7b 5c 74 74 20 |ze}..\it|em {\tt |
|00001a20| 3a 69 6e 69 74 66 6f 72 | 6d 7d 5c 73 63 68 69 6e |:initfor|m}\schin|
|00001a30| 64 65 78 7b 3a 69 6e 69 | 74 66 6f 72 6d 7d 5c 73 |dex{:ini|tform}\s|
|00001a40| 63 68 69 6e 64 65 78 7b | 64 65 66 61 75 6c 74 20 |chindex{|default |
|00001a50| 73 6c 6f 74 20 76 61 6c | 75 65 7d 20 0a 70 65 72 |slot val|ue} .per|
|00001a60| 6d 69 74 73 20 74 6f 20 | 73 75 70 70 6c 79 20 61 |mits to |supply a|
|00001a70| 20 64 65 66 61 75 6c 74 | 20 76 61 6c 75 65 20 66 | default| value f|
|00001a80| 6f 72 20 74 68 65 20 73 | 6c 6f 74 2e 20 54 68 69 |or the s|lot. Thi|
|00001a90| 73 20 64 65 66 61 75 6c | 74 20 76 61 6c 75 65 20 |s defaul|t value |
|00001aa0| 69 73 20 6f 62 74 61 69 | 6e 65 64 0a 62 79 20 65 |is obtai|ned.by e|
|00001ab0| 76 61 6c 75 61 74 69 6e | 67 20 74 68 65 20 66 6f |valuatin|g the fo|
|00001ac0| 72 6d 20 67 69 76 65 6e | 20 61 66 74 65 72 20 74 |rm given| after t|
|00001ad0| 68 65 20 7b 5c 74 74 20 | 3a 69 6e 69 74 66 6f 72 |he {\tt |:initfor|
|00001ae0| 6d 7d 20 69 6e 20 74 68 | 65 20 67 6c 6f 62 61 6c |m} in th|e global|
|00001af0| 0a 65 6e 76 69 72 6f 6e | 6d 65 6e 74 5c 6d 61 69 |.environ|ment\mai|
|00001b00| 6e 69 6e 64 65 78 7b 74 | 6f 70 20 6c 65 76 65 6c |nindex{t|op level|
|00001b10| 20 65 6e 76 69 72 6f 6e | 6d 65 6e 74 7d 2e 0a 0a | environ|ment}...|
|00001b20| 5c 69 74 65 6d 7b 5c 74 | 74 20 3a 69 6e 69 74 2d |\item{\t|t :init-|
|00001b30| 6b 65 79 77 6f 72 64 7d | 5c 73 63 68 69 6e 64 65 |keyword}|\schinde|
|00001b40| 78 7b 3a 69 6e 69 74 2d | 6b 65 79 77 6f 72 64 7d |x{:init-|keyword}|
|00001b50| 20 70 65 72 6d 69 74 73 | 20 74 6f 20 73 70 65 63 | permits| to spec|
|00001b60| 69 66 79 20 74 68 65 20 | 0a 6b 65 79 77 6f 72 64 |ify the |.keyword|
|00001b70| 20 66 6f 72 20 69 6e 69 | 74 69 61 6c 69 7a 69 6e | for ini|tializin|
|00001b80| 67 20 61 20 73 6c 6f 74 | 2e 20 54 68 65 20 69 6e |g a slot|. The in|
|00001b90| 69 74 2d 6b 65 79 77 6f | 72 64 20 6d 61 79 20 62 |it-keywo|rd may b|
|00001ba0| 65 20 70 72 6f 76 69 64 | 65 64 20 0a 64 75 72 69 |e provid|ed .duri|
|00001bb0| 6e 67 20 69 6e 73 74 61 | 6e 63 65 20 63 72 65 61 |ng insta|nce crea|
|00001bc0| 74 69 6f 6e 20 28 69 2e | 65 2e 20 69 6e 20 74 68 |tion (i.|e. in th|
|00001bd0| 65 20 6d 61 6b 65 20 6f | 70 74 69 6f 6e 61 6c 20 |e make o|ptional |
|00001be0| 70 61 72 61 6d 65 74 65 | 72 20 6c 69 73 74 29 2e |paramete|r list).|
|00001bf0| 20 53 70 65 63 69 66 79 | 69 6e 67 20 0a 73 75 63 | Specify|ing .suc|
|00001c00| 68 20 61 20 6b 65 79 77 | 6f 72 64 20 64 75 72 69 |h a keyw|ord duri|
|00001c10| 6e 67 20 69 6e 73 74 61 | 6e 63 65 20 69 6e 69 74 |ng insta|nce init|
|00001c20| 69 61 6c 69 7a 61 74 69 | 6f 6e 20 77 69 6c 6c 20 |ializati|on will |
|00001c30| 73 75 70 65 72 73 65 64 | 65 20 74 68 65 20 0a 64 |supersed|e the .d|
|00001c40| 65 66 61 75 6c 74 20 73 | 6c 6f 74 20 69 6e 69 74 |efault s|lot init|
|00001c50| 69 61 6c 69 7a 61 74 69 | 6f 6e 20 70 6f 73 73 69 |ializati|on possi|
|00001c60| 62 6c 79 20 67 69 76 65 | 6e 20 77 69 74 68 20 7b |bly give|n with {|
|00001c70| 5c 74 74 20 3a 69 6e 69 | 74 66 6f 72 6d 7d 2e 0a |\tt :ini|tform}..|
|00001c80| 0a 5c 69 74 65 6d 20 7b | 5c 74 74 20 3a 67 65 74 |.\item {|\tt :get|
|00001c90| 74 65 72 7d 7b 5c 73 63 | 68 69 6e 64 65 78 7b 3a |ter}{\sc|hindex{:|
|00001ca0| 67 65 74 74 65 72 7d 7d | 20 70 65 72 6d 69 74 73 |getter}}| permits|
|00001cb0| 20 74 6f 20 73 75 70 70 | 6c 79 20 74 68 65 20 6e | to supp|ly the n|
|00001cc0| 61 6d 65 20 66 6f 72 20 | 74 68 65 20 0a 73 6c 6f |ame for |the .slo|
|00001cd0| 74 20 67 65 74 74 65 72 | 5c 6d 61 69 6e 69 6e 64 |t getter|\mainind|
|00001ce0| 65 78 7b 67 65 74 74 65 | 72 7d 2e 20 54 68 65 20 |ex{gette|r}. The |
|00001cf0| 6e 61 6d 65 20 62 69 6e | 64 69 6e 67 20 69 73 20 |name bin|ding is |
|00001d00| 64 6f 6e 65 20 69 6e 20 | 74 68 65 20 67 6c 6f 62 |done in |the glob|
|00001d10| 61 6c 20 0a 65 6e 76 69 | 72 6f 6e 6d 65 6e 74 5c |al .envi|ronment\|
|00001d20| 6d 61 69 6e 69 6e 64 65 | 78 7b 74 6f 70 20 6c 65 |maininde|x{top le|
|00001d30| 76 65 6c 20 65 6e 76 69 | 72 6f 6e 6d 65 6e 74 7d |vel envi|ronment}|
|00001d40| 2e 0a 0a 5c 69 74 65 6d | 20 7b 5c 74 74 20 3a 73 |...\item| {\tt :s|
|00001d50| 65 74 74 65 72 7d 7b 5c | 73 63 68 69 6e 64 65 78 |etter}{\|schindex|
|00001d60| 7b 3a 73 65 74 74 65 72 | 7d 7d 20 70 65 72 6d 69 |{:setter|}} permi|
|00001d70| 74 73 20 74 6f 20 73 75 | 70 70 6c 79 20 74 68 65 |ts to su|pply the|
|00001d80| 20 6e 61 6d 65 20 66 6f | 72 20 74 68 65 20 0a 73 | name fo|r the .s|
|00001d90| 6c 6f 74 20 73 65 74 74 | 65 72 5c 6d 61 69 6e 69 |lot sett|er\maini|
|00001da0| 6e 64 65 78 7b 73 65 74 | 74 65 72 7d 2e 20 54 68 |ndex{set|ter}. Th|
|00001db0| 65 20 6e 61 6d 65 20 62 | 69 6e 64 69 6e 67 20 69 |e name b|inding i|
|00001dc0| 73 20 64 6f 6e 65 20 69 | 6e 20 74 68 65 20 67 6c |s done i|n the gl|
|00001dd0| 6f 62 61 6c 20 0a 65 6e | 76 69 72 6f 6e 6d 65 6e |obal .en|vironmen|
|00001de0| 74 5c 6d 61 69 6e 69 6e | 64 65 78 7b 74 6f 70 20 |t\mainin|dex{top |
|00001df0| 6c 65 76 65 6c 20 65 6e | 76 69 72 6f 6e 6d 65 6e |level en|vironmen|
|00001e00| 74 7d 2e 0a 0a 5c 69 74 | 65 6d 20 7b 5c 74 74 20 |t}...\it|em {\tt |
|00001e10| 3a 61 63 63 65 73 73 6f | 72 7d 5c 73 63 68 69 6e |:accesso|r}\schin|
|00001e20| 64 65 78 7b 3a 61 63 63 | 65 73 73 6f 72 7d 20 70 |dex{:acc|essor} p|
|00001e30| 65 72 6d 69 74 73 20 74 | 6f 20 73 75 70 70 6c 79 |ermits t|o supply|
|00001e40| 20 74 68 65 20 6e 61 6d | 65 20 66 6f 72 20 74 68 | the nam|e for th|
|00001e50| 65 20 0a 73 6c 6f 74 20 | 61 63 63 65 73 73 6f 72 |e .slot |accessor|
|00001e60| 5c 6d 61 69 6e 69 6e 64 | 65 78 7b 61 63 63 65 73 |\mainind|ex{acces|
|00001e70| 73 6f 72 7d 2e 20 54 68 | 65 20 6e 61 6d 65 20 62 |sor}. Th|e name b|
|00001e80| 69 6e 64 69 6e 67 20 69 | 73 20 64 6f 6e 65 20 69 |inding i|s done i|
|00001e90| 6e 20 74 68 65 20 67 6c | 6f 62 61 6c 0a 65 6e 76 |n the gl|obal.env|
|00001ea0| 69 72 6f 6e 6d 65 6e 74 | 5c 6d 61 69 6e 69 6e 64 |ironment|\mainind|
|00001eb0| 65 78 7b 74 6f 70 20 6c | 65 76 65 6c 20 65 6e 76 |ex{top l|evel env|
|00001ec0| 69 72 6f 6e 6d 65 6e 74 | 7d 2e 20 41 6e 20 61 63 |ironment|}. An ac|
|00001ed0| 63 65 73 73 6f 72 20 70 | 65 72 6d 69 74 73 20 74 |cessor p|ermits t|
|00001ee0| 6f 20 67 65 74 20 61 6e | 64 0a 73 65 74 20 74 68 |o get an|d.set th|
|00001ef0| 65 20 76 61 6c 75 65 20 | 6f 66 20 61 20 73 6c 6f |e value |of a slo|
|00001f00| 74 2e 20 53 65 74 74 69 | 6e 67 20 74 68 65 20 76 |t. Setti|ng the v|
|00001f10| 61 6c 75 65 20 6f 66 20 | 61 20 73 6c 6f 74 20 69 |alue of |a slot i|
|00001f20| 73 20 64 6f 6e 65 20 77 | 69 74 68 20 74 68 65 20 |s done w|ith the |
|00001f30| 65 78 74 65 6e 64 65 64 | 0a 76 65 72 73 69 6f 6e |extended|.version|
|00001f40| 20 6f 66 20 7b 5c 74 74 | 20 73 65 74 21 7d 5c 73 | of {\tt| set!}\s|
|00001f50| 63 68 69 6e 64 65 78 7b | 73 65 74 21 7d 2e 0a 0a |chindex{|set!}...|
|00001f60| 5c 69 74 65 6d 20 7b 5c | 74 74 20 3a 61 6c 6c 6f |\item {\|tt :allo|
|00001f70| 63 61 74 69 6f 6e 7d 5c | 73 63 68 69 6e 64 65 78 |cation}\|schindex|
|00001f80| 7b 3a 61 6c 6c 6f 63 61 | 74 69 6f 6e 7d 20 70 65 |{:alloca|tion} pe|
|00001f90| 72 6d 69 74 73 20 74 6f | 20 73 70 65 63 69 66 79 |rmits to| specify|
|00001fa0| 20 68 6f 77 20 73 74 6f | 72 61 67 65 20 66 6f 72 | how sto|rage for|
|00001fb0| 0a 74 68 65 20 73 6c 6f | 74 20 69 73 20 61 6c 6c |.the slo|t is all|
|00001fc0| 6f 63 61 74 65 64 2e 20 | 54 68 72 65 65 20 6b 69 |ocated. |Three ki|
|00001fd0| 6e 64 73 20 6f 66 20 61 | 6c 6c 6f 63 61 74 69 6f |nds of a|llocatio|
|00001fe0| 6e 20 61 72 65 20 70 72 | 6f 76 69 64 65 64 2e 20 |n are pr|ovided. |
|00001ff0| 0a 54 68 65 79 20 61 72 | 65 20 64 65 73 63 72 69 |.They ar|e descri|
|00002000| 62 65 64 20 62 65 6c 6f | 77 3a 0a 20 20 5c 62 65 |bed belo|w:. \be|
|00002010| 67 69 6e 7b 69 74 65 6d | 69 7a 65 7d 0a 20 20 20 |gin{item|ize}. |
|00002020| 20 20 5c 69 74 65 6d 20 | 7b 5c 74 74 20 3a 69 6e | \item |{\tt :in|
|00002030| 73 74 61 6e 63 65 7d 5c | 73 63 68 69 6e 64 65 78 |stance}\|schindex|
|00002040| 7b 3a 69 6e 73 74 61 6e | 63 65 7d 20 69 6e 64 69 |{:instan|ce} indi|
|00002050| 63 61 74 65 73 20 74 68 | 61 74 20 65 61 63 68 20 |cates th|at each |
|00002060| 69 6e 73 74 61 6e 63 65 | 20 67 65 74 73 0a 20 20 |instance| gets. |
|00002070| 20 20 20 69 74 73 20 6f | 77 6e 20 73 74 6f 72 61 | its o|wn stora|
|00002080| 67 65 20 66 6f 72 20 74 | 68 65 20 73 6c 6f 74 2e |ge for t|he slot.|
|00002090| 20 54 68 69 73 20 69 73 | 20 74 68 65 20 64 65 66 | This is| the def|
|000020a0| 61 75 6c 74 2e 0a 20 20 | 20 20 20 5c 69 74 65 6d |ault.. | \item|
|000020b0| 20 7b 5c 74 74 20 3a 63 | 6c 61 73 73 7d 5c 73 63 | {\tt :c|lass}\sc|
|000020c0| 68 69 6e 64 65 78 7b 3a | 63 6c 61 73 73 7d 20 69 |hindex{:|class} i|
|000020d0| 6e 64 69 63 61 74 65 73 | 20 74 68 61 74 20 74 68 |ndicates| that th|
|000020e0| 65 72 65 20 69 73 20 6f | 6e 65 20 73 74 6f 72 61 |ere is o|ne stora|
|000020f0| 67 65 20 0a 20 20 20 20 | 20 6c 6f 63 61 74 69 6f |ge . | locatio|
|00002100| 6e 20 75 73 65 64 20 62 | 79 20 61 6c 6c 20 74 68 |n used b|y all th|
|00002110| 65 20 64 69 72 65 63 74 | 20 61 6e 64 20 69 6e 64 |e direct| and ind|
|00002120| 69 72 65 63 74 20 69 6e | 73 74 61 6e 63 65 73 20 |irect in|stances |
|00002130| 6f 66 20 74 68 65 20 63 | 6c 61 73 73 2e 20 54 68 |of the c|lass. Th|
|00002140| 69 73 20 0a 20 20 20 20 | 20 70 65 72 6d 69 74 73 |is . | permits|
|00002150| 20 74 6f 20 64 65 66 69 | 6e 65 20 61 20 6b 69 6e | to defi|ne a kin|
|00002160| 64 20 6f 66 20 67 6c 6f | 62 61 6c 20 76 61 72 69 |d of glo|bal vari|
|00002170| 61 62 6c 65 20 77 68 69 | 63 68 20 63 61 6e 20 62 |able whi|ch can b|
|00002180| 65 20 61 63 63 65 73 73 | 65 64 20 6f 6e 6c 79 20 |e access|ed only |
|00002190| 0a 20 20 20 20 20 62 79 | 20 28 69 6e 29 64 69 72 |. by| (in)dir|
|000021a0| 65 63 74 20 69 6e 73 74 | 61 6e 63 65 73 20 6f 66 |ect inst|ances of|
|000021b0| 20 74 68 65 20 63 6c 61 | 73 73 20 77 68 69 63 68 | the cla|ss which|
|000021c0| 20 64 65 66 69 6e 65 73 | 20 74 68 69 73 20 73 6c | defines| this sl|
|000021d0| 6f 74 2e 0a 20 20 20 20 | 20 5c 69 74 65 6d 20 7b |ot.. | \item {|
|000021e0| 5c 74 74 20 3a 76 69 72 | 74 75 61 6c 7d 5c 73 63 |\tt :vir|tual}\sc|
|000021f0| 68 69 6e 64 65 78 7b 3a | 76 69 72 74 75 61 6c 7d |hindex{:|virtual}|
|00002200| 20 69 6e 64 69 63 61 74 | 65 73 20 74 68 61 74 20 | indicat|es that |
|00002210| 6e 6f 20 73 74 6f 72 61 | 67 65 20 77 69 6c 6c 0a |no stora|ge will.|
|00002220| 20 20 20 20 20 62 65 20 | 61 6c 6c 6f 63 61 74 65 | be |allocate|
|00002230| 64 20 66 6f 72 20 74 68 | 69 73 20 73 6c 6f 74 2e |d for th|is slot.|
|00002240| 20 20 49 74 20 69 73 20 | 75 70 20 74 6f 20 74 68 | It is |up to th|
|00002250| 65 20 75 73 65 72 20 74 | 6f 20 64 65 66 69 6e 65 |e user t|o define|
|00002260| 20 61 20 67 65 74 74 65 | 72 20 0a 20 20 20 20 20 | a gette|r . |
|00002270| 61 6e 64 20 61 20 73 65 | 74 74 65 72 20 66 75 6e |and a se|tter fun|
|00002280| 63 74 69 6f 6e 20 66 6f | 72 20 74 68 69 73 20 73 |ction fo|r this s|
|00002290| 6c 6f 74 2e 20 54 68 6f | 73 65 20 66 75 6e 63 74 |lot. Tho|se funct|
|000022a0| 69 6f 6e 73 20 6d 75 73 | 74 20 62 65 20 64 65 66 |ions mus|t be def|
|000022b0| 69 6e 65 64 20 77 69 74 | 68 20 74 68 65 0a 20 20 |ined wit|h the. |
|000022c0| 20 20 20 7b 5c 74 74 20 | 3a 73 6c 6f 74 2d 72 65 | {\tt |:slot-re|
|000022d0| 66 7d 5c 73 63 68 69 6e | 64 65 78 7b 3a 73 6c 6f |f}\schin|dex{:slo|
|000022e0| 74 2d 72 65 66 7d 0a 20 | 20 20 20 20 20 61 6e 64 |t-ref}. | and|
|000022f0| 20 7b 5c 74 74 20 3a 73 | 6c 6f 74 2d 73 65 74 21 | {\tt :s|lot-set!|
|00002300| 7d 5c 73 63 68 69 6e 64 | 65 78 7b 3a 73 6c 6f 74 |}\schind|ex{:slot|
|00002310| 2d 73 65 74 21 7d 20 6f | 70 74 69 6f 6e 73 2e 20 |-set!} o|ptions. |
|00002320| 53 65 65 20 74 68 65 20 | 65 78 61 6d 70 6c 65 20 |See the |example |
|00002330| 62 65 6c 6f 77 2e 0a 20 | 20 5c 65 6e 64 7b 69 74 |below.. | \end{it|
|00002340| 65 6d 69 7a 65 7d 0a 5c | 65 6e 64 7b 69 74 65 6d |emize}.\|end{item|
|00002350| 69 7a 65 7d 0a 0a 54 6f | 20 69 6c 6c 75 73 74 72 |ize}..To| illustr|
|00002360| 61 74 65 20 73 6c 6f 74 | 20 64 65 73 63 72 69 70 |ate slot| descrip|
|00002370| 74 69 6f 6e 2c 20 77 65 | 20 73 68 61 6c 6c 20 72 |tion, we| shall r|
|00002380| 65 64 65 66 69 6e 65 20 | 74 68 65 20 7b 5c 74 74 |edefine |the {\tt|
|00002390| 20 3c 63 6f 6d 70 6c 65 | 78 3e 7d 20 63 6c 61 73 | <comple|x>} clas|
|000023a0| 73 20 0a 73 65 65 6e 20 | 62 65 66 6f 72 65 2e 20 |s .seen |before. |
|000023b0| 41 20 64 65 66 69 6e 69 | 74 69 6f 6e 20 63 6f 75 |A defini|tion cou|
|000023c0| 6c 64 20 62 65 3a 0a 5c | 62 65 67 69 6e 7b 73 63 |ld be:.\|begin{sc|
|000023d0| 68 65 6d 65 7d 0a 28 64 | 65 66 69 6e 65 2d 63 6c |heme}.(d|efine-cl|
|000023e0| 61 73 73 20 3c 63 6f 6d | 70 6c 65 78 3e 20 28 3c |ass <com|plex> (<|
|000023f0| 6e 75 6d 62 65 72 3e 29 | 20 0a 20 20 20 28 28 72 |number>)| . ((r|
|00002400| 20 3a 69 6e 69 74 66 6f | 72 6d 20 30 20 3a 67 65 | :initfo|rm 0 :ge|
|00002410| 74 74 65 72 20 67 65 74 | 2d 72 20 3a 73 65 74 74 |tter get|-r :sett|
|00002420| 65 72 20 73 65 74 2d 72 | 21 20 3a 69 6e 69 74 2d |er set-r|! :init-|
|00002430| 6b 65 79 77 6f 72 64 20 | 3a 72 29 0a 20 20 20 20 |keyword |:r). |
|00002440| 28 69 20 3a 69 6e 69 74 | 66 6f 72 6d 20 30 20 3a |(i :init|form 0 :|
|00002450| 67 65 74 74 65 72 20 67 | 65 74 2d 69 20 3a 73 65 |getter g|et-i :se|
|00002460| 74 74 65 72 20 73 65 74 | 2d 69 21 20 3a 69 6e 69 |tter set|-i! :ini|
|00002470| 74 2d 6b 65 79 77 6f 72 | 64 20 3a 69 29 29 29 0a |t-keywor|d :i))).|
|00002480| 5c 65 6e 64 7b 73 63 68 | 65 6d 65 7d 0a 57 69 74 |\end{sch|eme}.Wit|
|00002490| 68 20 74 68 69 73 20 64 | 65 66 69 6e 69 74 69 6f |h this d|efinitio|
|000024a0| 6e 2c 20 74 68 65 20 7b | 5c 74 74 20 72 7d 20 61 |n, the {|\tt r} a|
|000024b0| 6e 64 20 7b 5c 74 74 20 | 69 7d 20 73 6c 6f 74 20 |nd {\tt |i} slot |
|000024c0| 61 72 65 20 73 65 74 20 | 74 6f 20 30 20 62 79 20 |are set |to 0 by |
|000024d0| 64 65 66 61 75 6c 74 2e | 20 0a 56 61 6c 75 65 20 |default.| .Value |
|000024e0| 6f 66 20 61 20 73 6c 6f | 74 20 63 61 6e 20 61 6c |of a slo|t can al|
|000024f0| 73 6f 20 62 65 20 73 70 | 65 63 69 66 69 65 64 20 |so be sp|ecified |
|00002500| 62 79 20 63 61 6c 6c 69 | 6e 67 20 7b 5c 74 74 20 |by calli|ng {\tt |
|00002510| 6d 61 6b 65 7d 20 77 69 | 74 68 20 0a 74 68 65 20 |make} wi|th .the |
|00002520| 7b 5c 74 74 20 3a 72 7d | 20 61 6e 64 20 7b 5c 74 |{\tt :r}| and {\t|
|00002530| 74 20 3a 69 7d 20 6b 65 | 79 77 6f 72 64 73 2e 20 |t :i} ke|ywords. |
|00002540| 46 75 72 74 68 65 72 6d | 6f 72 65 2c 20 74 68 65 |Furtherm|ore, the|
|00002550| 20 67 65 6e 65 72 69 63 | 20 66 75 6e 63 74 69 6f | generic| functio|
|00002560| 6e 73 20 7b 5c 74 74 20 | 67 65 74 2d 72 7d 20 0a |ns {\tt |get-r} .|
|00002570| 61 6e 64 20 7b 5c 74 74 | 20 73 65 74 2d 72 21 7d |and {\tt| set-r!}|
|00002580| 20 28 72 65 73 70 2e 20 | 7b 5c 74 74 20 67 65 74 | (resp. |{\tt get|
|00002590| 2d 69 7d 20 61 6e 64 20 | 7b 5c 74 74 20 73 65 74 |-i} and |{\tt set|
|000025a0| 2d 69 21 7d 29 20 61 72 | 65 20 61 75 74 6f 6d 61 |-i!}) ar|e automa|
|000025b0| 74 69 63 61 6c 6c 79 20 | 64 65 66 69 6e 65 64 0a |tically |defined.|
|000025c0| 62 79 20 74 68 65 20 73 | 79 73 74 65 6d 20 74 6f |by the s|ystem to|
|000025d0| 20 72 65 61 64 20 61 6e | 64 20 77 72 69 74 65 20 | read an|d write |
|000025e0| 74 68 65 20 7b 5c 74 74 | 20 72 7d 20 28 72 65 73 |the {\tt| r} (res|
|000025f0| 70 2e 20 7b 5c 74 74 20 | 69 7d 29 20 73 6c 6f 74 |p. {\tt |i}) slot|
|00002600| 2e 0a 5c 62 65 67 69 6e | 7b 73 63 68 65 6d 65 7d |..\begin|{scheme}|
|00002610| 0a 28 64 65 66 69 6e 65 | 20 63 31 20 28 6d 61 6b |.(define| c1 (mak|
|00002620| 65 20 3c 63 6f 6d 70 6c | 65 78 3e 20 3a 72 20 31 |e <compl|ex> :r 1|
|00002630| 20 3a 69 20 32 29 29 0a | 28 67 65 74 2d 72 20 63 | :i 2)).|(get-r c|
|00002640| 31 29 20 5c 6c 65 76 20 | 31 0a 28 73 65 74 2d 72 |1) \lev |1.(set-r|
|00002650| 21 20 63 31 20 31 32 29 | 0a 28 67 65 74 2d 72 20 |! c1 12)|.(get-r |
|00002660| 63 31 29 20 5c 6c 65 76 | 20 31 32 0a 28 64 65 66 |c1) \lev| 12.(def|
|00002670| 69 6e 65 20 63 32 20 28 | 6d 61 6b 65 20 3c 63 6f |ine c2 (|make <co|
|00002680| 6d 70 6c 65 78 3e 20 3a | 72 20 32 29 29 0a 28 67 |mplex> :|r 2)).(g|
|00002690| 65 74 2d 72 20 63 32 29 | 20 5c 6c 65 76 20 32 0a |et-r c2)| \lev 2.|
|000026a0| 28 67 65 74 2d 69 20 63 | 32 29 20 5c 6c 65 76 20 |(get-i c|2) \lev |
|000026b0| 30 0a 5c 65 6e 64 7b 73 | 63 68 65 6d 65 7d 0a 0a |0.\end{s|cheme}..|
|000026c0| 41 63 63 65 73 73 6f 72 | 73 20 70 72 6f 76 69 64 |Accessor|s provid|
|000026d0| 65 20 61 6e 20 75 6e 69 | 66 6f 72 6d 20 61 63 63 |e an uni|form acc|
|000026e0| 65 73 73 20 66 6f 72 20 | 72 65 61 64 69 6e 67 20 |ess for |reading |
|000026f0| 61 6e 64 20 77 72 69 74 | 69 6e 67 20 61 6e 20 6f |and writ|ing an o|
|00002700| 62 6a 65 63 74 20 73 6c | 6f 74 2e 0a 57 72 69 74 |bject sl|ot..Writ|
|00002710| 69 6e 67 20 61 20 73 6c | 6f 74 20 69 73 20 64 6f |ing a sl|ot is do|
|00002720| 6e 65 20 77 69 74 68 20 | 61 6e 20 65 78 74 65 6e |ne with |an exten|
|00002730| 64 65 64 20 66 6f 72 6d | 20 6f 66 20 7b 5c 74 74 |ded form| of {\tt|
|00002740| 20 73 65 74 21 7d 5c 73 | 63 68 69 6e 64 65 78 7b | set!}\s|chindex{|
|00002750| 73 65 74 21 7d 0a 77 68 | 69 63 68 20 69 73 20 63 |set!}.wh|ich is c|
|00002760| 6c 6f 73 65 20 74 6f 20 | 74 68 65 20 20 43 6f 6d |lose to |the Com|
|00002770| 6d 6f 6e 20 4c 69 73 70 | 20 7b 5c 74 74 20 73 65 |mon Lisp| {\tt se|
|00002780| 74 66 7d 20 6d 61 63 72 | 6f 2e 20 53 6f 2c 20 61 |tf} macr|o. So, a|
|00002790| 6e 6f 74 68 65 72 20 64 | 65 66 69 6e 69 74 69 6f |nother d|efinitio|
|000027a0| 6e 20 6f 66 20 74 68 65 | 0a 70 72 65 76 69 6f 75 |n of the|.previou|
|000027b0| 73 20 7b 5c 74 74 20 3c | 63 6f 6d 70 6c 65 78 3e |s {\tt <|complex>|
|000027c0| 7d 20 63 6c 61 73 73 2c | 20 75 73 69 6e 67 20 74 |} class,| using t|
|000027d0| 68 65 20 7b 5c 74 74 20 | 3a 61 63 63 65 73 73 6f |he {\tt |:accesso|
|000027e0| 72 7d 20 6f 70 74 69 6f | 6e 2c 20 63 6f 75 6c 64 |r} optio|n, could|
|000027f0| 20 62 65 3a 0a 5c 62 65 | 67 69 6e 7b 73 63 68 65 | be:.\be|gin{sche|
|00002800| 6d 65 7d 0a 28 64 65 66 | 69 6e 65 2d 63 6c 61 73 |me}.(def|ine-clas|
|00002810| 73 20 3c 63 6f 6d 70 6c | 65 78 3e 20 28 3c 6e 75 |s <compl|ex> (<nu|
|00002820| 6d 62 65 72 3e 29 20 0a | 20 20 20 28 28 72 20 3a |mber>) .| ((r :|
|00002830| 69 6e 69 74 66 6f 72 6d | 20 30 20 3a 61 63 63 65 |initform| 0 :acce|
|00002840| 73 73 6f 72 20 72 65 61 | 6c 2d 70 61 72 74 20 3a |ssor rea|l-part :|
|00002850| 69 6e 69 74 2d 6b 65 79 | 77 6f 72 64 20 3a 72 29 |init-key|word :r)|
|00002860| 0a 20 20 20 20 28 69 20 | 3a 69 6e 69 74 66 6f 72 |. (i |:initfor|
|00002870| 6d 20 30 20 3a 61 63 63 | 65 73 73 6f 72 20 69 6d |m 0 :acc|essor im|
|00002880| 61 67 2d 70 61 72 74 20 | 3a 69 6e 69 74 2d 6b 65 |ag-part |:init-ke|
|00002890| 79 77 6f 72 64 20 3a 69 | 29 29 29 0a 5c 65 6e 64 |yword :i|))).\end|
|000028a0| 7b 73 63 68 65 6d 65 7d | 0a 0a 55 73 69 6e 67 20 |{scheme}|..Using |
|000028b0| 74 68 69 73 20 63 6c 61 | 73 73 20 64 65 66 69 6e |this cla|ss defin|
|000028c0| 69 74 69 6f 6e 2c 20 72 | 65 61 64 69 6e 67 20 74 |ition, r|eading t|
|000028d0| 68 65 20 72 65 61 6c 20 | 70 61 72 74 20 6f 66 20 |he real |part of |
|000028e0| 74 68 65 20 7b 5c 74 74 | 20 63 7d 20 63 6f 6d 70 |the {\tt| c} comp|
|000028f0| 6c 65 78 20 63 61 6e 0a | 62 65 20 64 6f 6e 65 20 |lex can.|be done |
|00002900| 77 69 74 68 3a 0a 5c 62 | 65 67 69 6e 7b 73 63 68 |with:.\b|egin{sch|
|00002910| 65 6d 65 7d 0a 28 72 65 | 61 6c 2d 70 61 72 74 20 |eme}.(re|al-part |
|00002920| 63 29 0a 5c 65 6e 64 7b | 73 63 68 65 6d 65 7d 0a |c).\end{|scheme}.|
|00002930| 61 6e 64 20 73 65 74 74 | 69 6e 67 20 69 74 20 74 |and sett|ing it t|
|00002940| 6f 20 74 68 65 20 76 61 | 6c 75 65 20 63 6f 6e 74 |o the va|lue cont|
|00002950| 61 69 6e 65 64 20 69 6e | 20 74 68 65 20 7b 5c 74 |ained in| the {\t|
|00002960| 74 20 6e 65 77 2d 76 61 | 6c 75 65 7d 20 76 61 72 |t new-va|lue} var|
|00002970| 69 61 62 6c 65 20 0a 63 | 61 6e 20 62 65 20 64 6f |iable .c|an be do|
|00002980| 6e 65 20 75 73 69 6e 67 | 20 74 68 65 20 65 78 74 |ne using| the ext|
|00002990| 65 6e 64 65 64 20 66 6f | 72 6d 20 6f 66 20 7b 5c |ended fo|rm of {\|
|000029a0| 74 74 20 73 65 74 21 7d | 2e 0a 5c 62 65 67 69 6e |tt set!}|..\begin|
|000029b0| 7b 73 63 68 65 6d 65 7d | 0a 28 73 65 74 21 20 28 |{scheme}|.(set! (|
|000029c0| 72 65 61 6c 2d 70 61 72 | 74 20 63 29 20 6e 65 77 |real-par|t c) new|
|000029d0| 2d 76 61 6c 75 65 29 0a | 5c 65 6e 64 7b 73 63 68 |-value).|\end{sch|
|000029e0| 65 6d 65 7d 0a 0a 53 75 | 70 70 6f 73 65 20 6e 6f |eme}..Su|ppose no|
|000029f0| 77 20 74 68 61 74 20 77 | 65 20 68 61 76 65 20 74 |w that w|e have t|
|00002a00| 6f 20 6d 61 6e 69 70 75 | 6c 61 74 65 20 63 6f 6d |o manipu|late com|
|00002a10| 70 6c 65 78 20 6e 75 6d | 62 65 72 73 20 77 69 74 |plex num|bers wit|
|00002a20| 68 20 72 65 63 74 61 6e | 67 75 6c 61 72 0a 63 6f |h rectan|gular.co|
|00002a30| 6f 72 64 69 6e 61 74 65 | 73 20 61 73 20 77 65 6c |ordinate|s as wel|
|00002a40| 6c 20 61 73 20 77 69 74 | 68 20 70 6f 6c 61 72 20 |l as wit|h polar |
|00002a50| 63 6f 6f 72 64 69 6e 61 | 74 65 73 2e 20 4f 6e 65 |coordina|tes. One|
|00002a60| 20 73 6f 6c 75 74 69 6f | 6e 20 63 6f 75 6c 64 20 | solutio|n could |
|00002a70| 62 65 20 74 6f 0a 68 61 | 76 65 20 61 20 64 65 66 |be to.ha|ve a def|
|00002a80| 69 6e 69 74 69 6f 6e 20 | 6f 66 20 63 6f 6d 70 6c |inition |of compl|
|00002a90| 65 78 20 6e 75 6d 62 65 | 72 73 20 77 68 69 63 68 |ex numbe|rs which|
|00002aa0| 20 75 73 65 73 20 6f 6e | 65 20 70 61 72 74 69 63 | uses on|e partic|
|00002ab0| 75 6c 61 72 20 72 65 70 | 72 65 73 65 6e 74 61 74 |ular rep|resentat|
|00002ac0| 69 6f 6e 0a 61 6e 64 20 | 73 6f 6d 65 20 63 6f 6e |ion.and |some con|
|00002ad0| 76 65 72 73 69 6f 6e 20 | 66 75 6e 63 74 69 6f 6e |version |function|
|00002ae0| 73 20 74 6f 20 70 61 73 | 73 20 66 72 6f 6d 20 6f |s to pas|s from o|
|00002af0| 6e 65 20 72 65 70 72 65 | 73 65 6e 74 61 74 69 6f |ne repre|sentatio|
|00002b00| 6e 20 74 6f 20 74 68 65 | 20 6f 74 68 65 72 2e 0a |n to the| other..|
|00002b10| 41 20 62 65 74 74 65 72 | 20 73 6f 6c 75 74 69 6f |A better| solutio|
|00002b20| 6e 20 75 73 65 73 20 76 | 69 72 74 75 61 6c 20 73 |n uses v|irtual s|
|00002b30| 6c 6f 74 73 2e 20 41 20 | 63 6f 6d 70 6c 65 74 65 |lots. A |complete|
|00002b40| 20 64 65 66 69 6e 69 74 | 69 6f 6e 20 6f 66 20 74 | definit|ion of t|
|00002b50| 68 65 20 7b 5c 74 74 20 | 3c 63 6f 6d 70 6c 65 78 |he {\tt |<complex|
|00002b60| 3e 7d 0a 63 6c 61 73 73 | 20 75 73 69 6e 67 20 76 |>}.class| using v|
|00002b70| 69 72 74 75 61 6c 20 73 | 6c 6f 74 73 20 69 73 20 |irtual s|lots is |
|00002b80| 67 69 76 65 6e 20 69 6e | 20 46 69 67 75 72 65 7e |given in| Figure~|
|00002b90| 32 2e 0a 5c 62 65 67 69 | 6e 7b 66 69 67 75 72 65 |2..\begi|n{figure|
|00002ba0| 7d 0a 7b 5c 66 6f 6f 74 | 6e 6f 74 65 73 69 7a 65 |}.{\foot|notesize|
|00002bb0| 0a 5c 62 65 67 69 6e 7b | 71 75 6f 74 65 7d 0a 5c |.\begin{|quote}.\|
|00002bc0| 62 65 67 69 6e 7b 71 75 | 6f 74 65 7d 0a 5c 62 65 |begin{qu|ote}.\be|
|00002bd0| 67 69 6e 7b 76 65 72 62 | 61 74 69 6d 7d 0a 28 64 |gin{verb|atim}.(d|
|00002be0| 65 66 69 6e 65 2d 63 6c | 61 73 73 20 3c 63 6f 6d |efine-cl|ass <com|
|00002bf0| 70 6c 65 78 3e 20 28 3c | 6e 75 6d 62 65 72 3e 29 |plex> (<|number>)|
|00002c00| 0a 20 20 20 28 3b 3b 20 | 54 72 75 65 20 73 6c 6f |. (;; |True slo|
|00002c10| 74 73 20 75 73 65 20 72 | 65 63 74 61 6e 67 75 6c |ts use r|ectangul|
|00002c20| 61 72 20 63 6f 6f 72 64 | 69 6e 61 74 65 73 0a 20 |ar coord|inates. |
|00002c30| 20 20 20 28 72 20 3a 69 | 6e 69 74 66 6f 72 6d 20 | (r :i|nitform |
|00002c40| 30 20 3a 61 63 63 65 73 | 73 6f 72 20 72 65 61 6c |0 :acces|sor real|
|00002c50| 2d 70 61 72 74 20 3a 69 | 6e 69 74 2d 6b 65 79 77 |-part :i|nit-keyw|
|00002c60| 6f 72 64 20 3a 72 29 0a | 20 20 20 20 28 69 20 3a |ord :r).| (i :|
|00002c70| 69 6e 69 74 66 6f 72 6d | 20 30 20 3a 61 63 63 65 |initform| 0 :acce|
|00002c80| 73 73 6f 72 20 69 6d 61 | 67 2d 70 61 72 74 20 3a |ssor ima|g-part :|
|00002c90| 69 6e 69 74 2d 6b 65 79 | 77 6f 72 64 20 3a 69 29 |init-key|word :i)|
|00002ca0| 0a 20 20 20 20 3b 3b 20 | 56 69 72 74 75 61 6c 20 |. ;; |Virtual |
|00002cb0| 73 6c 6f 74 73 20 61 63 | 63 65 73 73 20 64 6f 20 |slots ac|cess do |
|00002cc0| 74 68 65 20 63 6f 6e 76 | 65 72 73 69 6f 6e 0a 20 |the conv|ersion. |
|00002cd0| 20 20 20 28 6d 20 3a 61 | 63 63 65 73 73 6f 72 20 | (m :a|ccessor |
|00002ce0| 6d 61 67 6e 69 74 75 64 | 65 20 3a 69 6e 69 74 2d |magnitud|e :init-|
|00002cf0| 6b 65 79 77 6f 72 64 20 | 3a 6d 61 67 6e 20 20 0a |keyword |:magn .|
|00002d00| 20 20 20 20 20 20 20 3a | 61 6c 6c 6f 63 61 74 69 | :|allocati|
|00002d10| 6f 6e 20 3a 76 69 72 74 | 75 61 6c 0a 20 20 20 20 |on :virt|ual. |
|00002d20| 20 20 20 3a 73 6c 6f 74 | 2d 72 65 66 20 28 6c 61 | :slot|-ref (la|
|00002d30| 6d 62 64 61 20 28 6f 29 | 0a 20 20 20 20 20 20 20 |mbda (o)|. |
|00002d40| 20 20 20 20 20 20 20 20 | 20 20 20 20 28 6c 65 74 | | (let|
|00002d50| 20 28 28 72 20 28 73 6c | 6f 74 2d 72 65 66 20 6f | ((r (sl|ot-ref o|
|00002d60| 20 27 72 29 29 20 28 69 | 20 28 73 6c 6f 74 2d 72 | 'r)) (i| (slot-r|
|00002d70| 65 66 20 6f 20 27 69 29 | 29 29 0a 20 20 20 20 20 |ef o 'i)|)). |
|00002d80| 20 20 20 20 20 20 20 20 | 20 20 20 20 20 20 20 20 | | |
|00002d90| 28 73 71 72 74 20 28 2b | 20 28 2a 20 72 20 72 29 |(sqrt (+| (* r r)|
|00002da0| 20 28 2a 20 69 20 69 29 | 29 29 29 29 0a 20 20 20 | (* i i)|)))). |
|00002db0| 20 20 20 20 3a 73 6c 6f | 74 2d 73 65 74 21 20 28 | :slo|t-set! (|
|00002dc0| 6c 61 6d 62 64 61 20 28 | 6f 20 6d 29 0a 20 20 20 |lambda (|o m). |
|00002dd0| 20 20 20 20 20 20 20 20 | 20 20 20 20 20 20 20 20 | | |
|00002de0| 20 20 28 6c 65 74 20 28 | 28 61 20 28 73 6c 6f 74 | (let (|(a (slot|
|00002df0| 2d 72 65 66 20 6f 20 27 | 61 29 29 29 0a 20 20 20 |-ref o '|a))). |
|00002e00| 20 20 20 20 20 20 20 20 | 20 20 20 20 20 20 20 20 | | |
|00002e10| 20 20 20 20 28 73 6c 6f | 74 2d 73 65 74 21 20 6f | (slo|t-set! o|
|00002e20| 20 27 72 20 28 2a 20 6d | 20 28 63 6f 73 20 61 29 | 'r (* m| (cos a)|
|00002e30| 29 29 0a 20 20 20 20 20 | 20 20 20 20 20 20 20 20 |)). | |
|00002e40| 20 20 20 20 20 20 20 20 | 20 20 28 73 6c 6f 74 2d | | (slot-|
|00002e50| 73 65 74 21 20 6f 20 27 | 69 20 28 2a 20 6d 20 28 |set! o '|i (* m (|
|00002e60| 73 69 6e 20 61 29 29 29 | 29 29 29 0a 20 20 20 20 |sin a)))|))). |
|00002e70| 28 61 20 3a 61 63 63 65 | 73 73 6f 72 20 61 6e 67 |(a :acce|ssor ang|
|00002e80| 6c 65 20 3a 69 6e 69 74 | 2d 6b 65 79 77 6f 72 64 |le :init|-keyword|
|00002e90| 20 3a 61 6e 67 6c 65 0a | 20 20 20 20 20 20 20 3a | :angle.| :|
|00002ea0| 61 6c 6c 6f 63 61 74 69 | 6f 6e 20 3a 76 69 72 74 |allocati|on :virt|
|00002eb0| 75 61 6c 0a 20 20 20 20 | 20 20 20 3a 73 6c 6f 74 |ual. | :slot|
|00002ec0| 2d 72 65 66 20 28 6c 61 | 6d 62 64 61 20 28 6f 29 |-ref (la|mbda (o)|
|00002ed0| 0a 20 20 20 20 20 20 20 | 20 20 20 20 20 20 20 20 |. | |
|00002ee0| 20 20 20 20 28 61 74 61 | 6e 20 28 73 6c 6f 74 2d | (ata|n (slot-|
|00002ef0| 72 65 66 20 6f 20 27 69 | 29 20 28 73 6c 6f 74 2d |ref o 'i|) (slot-|
|00002f00| 72 65 66 20 6f 20 27 72 | 29 29 29 0a 20 20 20 20 |ref o 'r|))). |
|00002f10| 20 20 20 3a 73 6c 6f 74 | 2d 73 65 74 21 20 28 6c | :slot|-set! (l|
|00002f20| 61 6d 62 64 61 28 6f 20 | 61 29 0a 20 20 20 20 20 |ambda(o |a). |
|00002f30| 20 20 20 20 20 20 20 20 | 20 20 20 20 20 20 20 28 | | (|
|00002f40| 6c 65 74 20 28 28 6d 20 | 28 73 6c 6f 74 2d 72 65 |let ((m |(slot-re|
|00002f50| 66 20 6f 20 27 6d 29 29 | 29 0a 20 20 20 20 20 20 |f o 'm))|). |
|00002f60| 20 20 20 20 20 20 20 20 | 20 20 20 20 20 20 20 20 | | |
|00002f70| 20 28 73 6c 6f 74 2d 73 | 65 74 21 20 6f 20 27 72 | (slot-s|et! o 'r|
|00002f80| 20 28 2a 20 6d 20 28 63 | 6f 73 20 61 29 29 29 0a | (* m (c|os a))).|
|00002f90| 20 20 20 20 20 20 20 20 | 20 20 20 20 20 20 20 20 | | |
|00002fa0| 20 20 20 20 20 20 20 28 | 73 6c 6f 74 2d 73 65 74 | (|slot-set|
|00002fb0| 21 20 6f 20 27 69 20 28 | 2a 20 6d 20 28 73 69 6e |! o 'i (|* m (sin|
|00002fc0| 20 61 29 29 29 29 29 29 | 29 29 0a 0a 5c 65 6e 64 | a))))))|))..\end|
|00002fd0| 7b 76 65 72 62 61 74 69 | 6d 7d 0a 5c 63 61 70 74 |{verbati|m}.\capt|
|00002fe0| 69 6f 6e 7b 5c 65 6d 20 | 41 20 7b 5c 74 74 20 3c |ion{\em |A {\tt <|
|00002ff0| 63 6f 6d 70 6c 65 78 3e | 7d 20 6e 75 6d 62 65 72 |complex>|} number|
|00003000| 20 63 6c 61 73 73 20 64 | 65 66 69 6e 69 74 69 6f | class d|efinitio|
|00003010| 6e 20 75 73 69 6e 67 20 | 76 69 72 74 75 61 6c 20 |n using |virtual |
|00003020| 73 6c 6f 74 73 7d 0a 5c | 65 6e 64 7b 71 75 6f 74 |slots}.\|end{quot|
|00003030| 65 7d 0a 5c 65 6e 64 7b | 71 75 6f 74 65 7d 0a 7d |e}.\end{|quote}.}|
|00003040| 0a 5c 65 6e 64 7b 66 69 | 67 75 72 65 7d 0a 0a 5c |.\end{fi|gure}..\|
|00003050| 62 69 67 73 6b 69 70 0a | 54 68 69 73 20 63 6c 61 |bigskip.|This cla|
|00003060| 73 73 20 64 65 66 69 6e | 69 74 69 6f 6e 20 69 6d |ss defin|ition im|
|00003070| 70 6c 65 6d 65 6e 74 73 | 20 74 77 6f 20 72 65 61 |plements| two rea|
|00003080| 6c 20 73 6c 6f 74 73 20 | 28 7b 5c 74 74 20 72 7d |l slots |({\tt r}|
|00003090| 20 61 6e 64 20 7b 5c 74 | 74 20 69 7d 29 2e 20 56 | and {\t|t i}). V|
|000030a0| 61 6c 75 65 73 0a 6f 66 | 20 74 68 65 20 7b 5c 74 |alues.of| the {\t|
|000030b0| 74 20 6d 7d 20 61 6e 64 | 20 7b 5c 74 74 20 61 7d |t m} and| {\tt a}|
|000030c0| 20 76 69 72 74 75 61 6c | 20 73 6c 6f 74 73 20 61 | virtual| slots a|
|000030d0| 72 65 20 63 61 6c 63 75 | 6c 61 74 65 64 20 66 72 |re calcu|lated fr|
|000030e0| 6f 6d 20 72 65 61 6c 20 | 73 6c 6f 74 0a 76 61 6c |om real |slot.val|
|000030f0| 75 65 73 2e 20 52 65 61 | 64 69 6e 67 20 61 20 76 |ues. Rea|ding a v|
|00003100| 69 72 74 75 61 6c 20 73 | 6c 6f 74 20 6c 65 61 64 |irtual s|lot lead|
|00003110| 73 20 74 6f 20 74 68 65 | 20 61 70 70 6c 69 63 61 |s to the| applica|
|00003120| 74 69 6f 6e 20 6f 66 20 | 74 68 65 20 66 75 6e 63 |tion of |the func|
|00003130| 74 69 6f 6e 0a 64 65 66 | 69 6e 65 64 20 69 6e 20 |tion.def|ined in |
|00003140| 74 68 65 20 7b 5c 74 74 | 20 3a 73 6c 6f 74 2d 72 |the {\tt| :slot-r|
|00003150| 65 66 7d 5c 73 63 68 69 | 6e 64 65 78 7b 3a 73 6c |ef}\schi|ndex{:sl|
|00003160| 6f 74 2d 72 65 66 7d 20 | 6f 70 74 69 6f 6e 2e 20 |ot-ref} |option. |
|00003170| 57 72 69 74 69 6e 67 20 | 73 75 63 68 20 61 20 73 |Writing |such a s|
|00003180| 6c 6f 74 20 0a 6c 65 61 | 64 73 20 74 6f 20 74 68 |lot .lea|ds to th|
|00003190| 65 20 61 70 70 6c 69 63 | 61 74 69 6f 6e 20 6f 66 |e applic|ation of|
|000031a0| 20 74 68 65 20 66 75 6e | 63 74 69 6f 6e 20 64 65 | the fun|ction de|
|000031b0| 66 69 6e 65 64 20 69 6e | 20 74 68 65 20 7b 5c 74 |fined in| the {\t|
|000031c0| 74 20 3a 73 6c 6f 74 2d | 73 65 74 21 7d 5c 73 63 |t :slot-|set!}\sc|
|000031d0| 68 69 6e 64 65 78 7b 3a | 73 6c 6f 74 2d 73 65 74 |hindex{:|slot-set|
|000031e0| 21 7d 20 6f 70 74 69 6f | 6e 2e 0a 46 6f 72 20 69 |!} optio|n..For i|
|000031f0| 6e 73 74 61 6e 63 65 2c | 20 74 68 65 20 66 6f 6c |nstance,| the fol|
|00003200| 6c 6f 77 69 6e 67 20 65 | 78 70 72 65 73 73 69 6f |lowing e|xpressio|
|00003210| 6e 0a 5c 62 65 67 69 6e | 7b 73 63 68 65 6d 65 7d |n.\begin|{scheme}|
|00003220| 0a 28 73 6c 6f 74 2d 73 | 65 74 21 20 63 20 27 61 |.(slot-s|et! c 'a|
|00003230| 20 33 29 0a 5c 65 6e 64 | 7b 73 63 68 65 6d 65 7d | 3).\end|{scheme}|
|00003240| 20 0a 70 65 72 6d 69 74 | 73 20 74 6f 20 73 65 74 | .permit|s to set|
|00003250| 20 74 68 65 20 61 6e 67 | 6c 65 20 6f 66 20 74 68 | the ang|le of th|
|00003260| 65 20 7b 5c 74 74 20 63 | 7d 20 63 6f 6d 70 6c 65 |e {\tt c|} comple|
|00003270| 78 20 6e 75 6d 62 65 72 | 2e 20 54 68 69 73 20 65 |x number|. This e|
|00003280| 78 70 72 65 73 73 69 6f | 6e 0a 63 6f 6e 64 75 63 |xpressio|n.conduc|
|00003290| 74 73 2c 20 69 6e 20 66 | 61 63 74 2c 20 74 6f 20 |ts, in f|act, to |
|000032a0| 74 68 65 20 65 76 61 6c | 75 61 74 69 6f 6e 20 6f |the eval|uation o|
|000032b0| 66 20 74 68 65 20 66 6f | 6c 6c 6f 77 69 6e 67 20 |f the fo|llowing |
|000032c0| 65 78 70 72 65 73 73 69 | 6f 6e 0a 5c 62 65 67 69 |expressi|on.\begi|
|000032d0| 6e 7b 73 63 68 65 6d 65 | 7d 0a 28 28 6c 61 6d 62 |n{scheme|}.((lamb|
|000032e0| 64 61 20 6f 20 6d 29 0a | 20 20 20 20 28 6c 65 74 |da o m).| (let|
|000032f0| 20 28 28 6d 20 28 73 6c | 6f 74 2d 72 65 66 20 6f | ((m (sl|ot-ref o|
|00003300| 20 27 6d 29 29 29 0a 20 | 20 20 20 20 20 20 28 73 | 'm))). | (s|
|00003310| 6c 6f 74 2d 73 65 74 21 | 20 6f 20 27 72 20 28 2a |lot-set!| o 'r (*|
|00003320| 20 6d 20 28 63 6f 73 20 | 61 29 29 29 0a 20 20 20 | m (cos |a))). |
|00003330| 20 20 20 20 28 73 6c 6f | 74 2d 73 65 74 21 20 6f | (slo|t-set! o|
|00003340| 20 27 69 20 28 2a 20 6d | 20 28 73 69 6e 20 61 29 | 'i (* m| (sin a)|
|00003350| 29 29 29 0a 20 20 63 20 | 33 29 0a 5c 65 6e 64 7b |))). c |3).\end{|
|00003360| 73 63 68 65 6d 65 7d 0a | 41 20 6d 6f 72 65 20 63 |scheme}.|A more c|
|00003370| 6f 6d 70 6c 65 74 65 20 | 65 78 61 6d 70 6c 65 20 |omplete |example |
|00003380| 69 73 20 67 69 76 65 6e | 20 62 65 6c 6f 77 3a 0a |is given| below:.|
|00003390| 5c 62 65 67 69 6e 7b 73 | 63 68 65 6d 65 7d 0a 28 |\begin{s|cheme}.(|
|000033a0| 64 65 66 69 6e 65 20 63 | 20 28 6d 61 6b 65 20 3c |define c| (make <|
|000033b0| 63 6f 6d 70 6c 65 78 3e | 20 3a 72 20 31 32 20 3a |complex>| :r 12 :|
|000033c0| 69 20 32 30 29 29 0a 28 | 72 65 61 6c 2d 70 61 72 |i 20)).(|real-par|
|000033d0| 74 20 63 29 20 5c 6c 65 | 76 20 31 32 0a 28 61 6e |t c) \le|v 12.(an|
|000033e0| 67 6c 65 20 63 29 20 5c | 6c 65 76 20 31 2e 30 33 |gle c) \|lev 1.03|
|000033f0| 30 33 37 36 38 32 36 35 | 32 34 33 31 0a 28 73 6c |03768265|2431.(sl|
|00003400| 6f 74 2d 73 65 74 21 20 | 63 20 27 69 20 31 30 29 |ot-set! |c 'i 10)|
|00003410| 0a 28 73 65 74 21 20 28 | 72 65 61 6c 2d 70 61 72 |.(set! (|real-par|
|00003420| 74 20 63 29 20 31 29 0a | 28 64 65 73 63 72 69 62 |t c) 1).|(describ|
|00003430| 65 20 63 29 20 5c 6c 65 | 76 20 0a 20 20 20 20 20 |e c) \le|v . |
|00003440| 20 20 20 20 20 5c 73 68 | 61 72 70 73 69 67 6e 5b | \sh|arpsign[|
|00003450| 3c 63 6f 6d 70 6c 65 78 | 3e 20 31 32 38 62 66 38 |<complex|> 128bf8|
|00003460| 5d 20 69 73 20 61 6e 20 | 69 6e 73 74 61 6e 63 65 |] is an |instance|
|00003470| 20 6f 66 20 63 6c 61 73 | 73 20 3c 63 6f 6d 70 6c | of clas|s <compl|
|00003480| 65 78 3e 0a 20 20 20 20 | 20 20 20 20 20 20 53 6c |ex>. | Sl|
|00003490| 6f 74 73 20 61 72 65 3a | 20 0a 20 20 20 20 20 20 |ots are:| . |
|000034a0| 20 20 20 20 20 20 20 20 | 20 72 20 3d 20 31 0a 20 | | r = 1. |
|000034b0| 20 20 20 20 20 20 20 20 | 20 20 20 20 20 20 69 20 | | i |
|000034c0| 3d 20 31 30 0a 20 20 20 | 20 20 20 20 20 20 20 20 |= 10. | |
|000034d0| 20 20 20 20 6d 20 3d 20 | 31 30 2e 30 34 39 38 37 | m = |10.04987|
|000034e0| 35 36 32 31 31 32 30 39 | 0a 20 20 20 20 20 20 20 |56211209|. |
|000034f0| 20 20 20 20 20 20 20 20 | 61 20 3d 20 31 2e 34 37 | |a = 1.47|
|00003500| 31 31 32 37 36 37 34 33 | 30 33 37 33 0a 5c 65 6e |11276743|0373.\en|
|00003510| 64 7b 73 63 68 65 6d 65 | 7d 0a 0a 53 69 6e 63 65 |d{scheme|}..Since|
|00003520| 20 69 6e 69 74 69 61 6c | 69 7a 61 74 69 6f 6e 20 | initial|ization |
|00003530| 6b 65 79 77 6f 72 64 73 | 20 68 61 76 65 20 62 65 |keywords| have be|
|00003540| 65 6e 20 64 65 66 69 6e | 65 64 20 66 6f 72 20 74 |en defin|ed for t|
|00003550| 68 65 20 66 6f 75 72 20 | 73 6c 6f 74 73 2c 20 77 |he four |slots, w|
|00003560| 65 0a 63 61 6e 20 6e 6f | 77 20 64 65 66 69 6e 65 |e.can no|w define|
|00003570| 20 74 68 65 20 5c 69 64 | 65 7b 6d 61 6b 65 2d 72 | the \id|e{make-r|
|00003580| 65 63 74 61 6e 67 75 6c | 61 72 7d 20 61 6e 64 20 |ectangul|ar} and |
|00003590| 5c 69 64 65 7b 6d 61 6b | 65 2d 70 6f 6c 61 72 7d |\ide{mak|e-polar}|
|000035a0| 0a 73 74 61 6e 64 61 72 | 64 20 53 63 68 65 6d 65 |.standar|d Scheme|
|000035b0| 20 70 72 69 6d 69 74 69 | 76 65 73 2e 0a 5c 62 65 | primiti|ves..\be|
|000035c0| 67 69 6e 7b 73 63 68 65 | 6d 65 7d 0a 28 64 65 66 |gin{sche|me}.(def|
|000035d0| 69 6e 65 20 6d 61 6b 65 | 2d 72 65 63 74 61 6e 67 |ine make|-rectang|
|000035e0| 75 6c 61 72 20 0a 20 20 | 20 28 6c 61 6d 62 64 61 |ular . | (lambda|
|000035f0| 20 28 78 20 79 29 20 28 | 6d 61 6b 65 20 3c 63 6f | (x y) (|make <co|
|00003600| 6d 70 6c 65 78 3e 20 3a | 72 20 78 20 3a 69 20 79 |mplex> :|r x :i y|
|00003610| 29 29 29 0a 0a 28 64 65 | 66 69 6e 65 20 6d 61 6b |)))..(de|fine mak|
|00003620| 65 2d 70 6f 6c 61 72 0a | 20 20 20 28 6c 61 6d 62 |e-polar.| (lamb|
|00003630| 64 61 20 28 78 20 79 29 | 20 28 6d 61 6b 65 20 3c |da (x y)| (make <|
|00003640| 63 6f 6d 70 6c 65 78 3e | 20 3a 6d 61 67 6e 20 78 |complex>| :magn x|
|00003650| 20 3a 61 6e 67 6c 65 20 | 79 29 29 29 0a 0a 5c 65 | :angle |y)))..\e|
|00003660| 6e 64 7b 73 63 68 65 6d | 65 7d 0a 0a 5c 73 75 62 |nd{schem|e}..\sub|
|00003670| 73 65 63 74 69 6f 6e 7b | 43 6c 61 73 73 20 70 72 |section{|Class pr|
|00003680| 65 63 65 64 65 6e 63 65 | 20 6c 69 73 74 7d 0a 0a |ecedence| list}..|
|00003690| 41 20 63 6c 61 73 73 20 | 6d 61 79 20 68 61 76 65 |A class |may have|
|000036a0| 20 6d 6f 72 65 20 74 68 | 61 6e 20 6f 6e 65 20 73 | more th|an one s|
|000036b0| 75 70 65 72 63 6c 61 73 | 73 2e 7b 5c 66 6f 6f 74 |uperclas|s.{\foot|
|000036c0| 6e 6f 74 65 7b 0a 54 68 | 69 73 20 73 65 63 74 69 |note{.Th|is secti|
|000036d0| 6f 6e 20 69 73 20 61 6e | 20 61 64 61 70 74 61 74 |on is an| adaptat|
|000036e0| 69 6f 6e 20 6f 66 20 4a | 65 66 66 20 44 61 6c 74 |ion of J|eff Dalt|
|000036f0| 6f 6e 27 73 20 28 4a 2e | 44 61 6c 74 6f 6e 40 65 |on's (J.|Dalton@e|
|00003700| 64 2e 61 63 2e 75 6b 29 | 0a 42 72 69 65 66 20 69 |d.ac.uk)|.Brief i|
|00003710| 6e 74 72 6f 64 75 63 74 | 69 6f 6e 20 74 6f 20 43 |ntroduct|ion to C|
|00003720| 4c 4f 53 29 7d 7d 0a 57 | 69 74 68 20 73 69 6e 67 |LOS)}}.W|ith sing|
|00003730| 6c 65 20 69 6e 68 65 72 | 69 74 61 6e 63 65 20 28 |le inher|itance (|
|00003740| 6f 6e 65 20 73 75 70 65 | 72 63 6c 61 73 73 29 2c |one supe|rclass),|
|00003750| 20 69 74 20 69 73 20 65 | 61 73 79 20 74 6f 20 6f | it is e|asy to o|
|00003760| 72 64 65 72 20 74 68 65 | 20 73 75 70 65 72 20 63 |rder the| super c|
|00003770| 6c 61 73 73 65 73 20 0a | 66 72 6f 6d 20 6d 6f 73 |lasses .|from mos|
|00003780| 74 20 74 6f 20 6c 65 61 | 73 74 20 73 70 65 63 69 |t to lea|st speci|
|00003790| 66 69 63 2e 20 54 68 69 | 73 20 69 73 20 74 68 65 |fic. Thi|s is the|
|000037a0| 20 72 75 6c 65 3a 0a 0a | 5c 62 65 67 69 6e 7b 71 | rule:..|\begin{q|
|000037b0| 75 6f 74 65 7d 0a 5c 62 | 65 67 69 6e 7b 71 75 6f |uote}.\b|egin{quo|
|000037c0| 74 65 7d 0a 7b 5c 62 66 | 20 52 75 6c 65 20 31 3a |te}.{\bf| Rule 1:|
|000037d0| 20 45 61 63 68 20 63 6c | 61 73 73 20 69 73 20 6d | Each cl|ass is m|
|000037e0| 6f 72 65 20 73 70 65 63 | 69 66 69 63 20 74 68 61 |ore spec|ific tha|
|000037f0| 6e 20 69 74 73 20 73 75 | 70 65 72 63 6c 61 73 73 |n its su|perclass|
|00003800| 65 73 2e 0a 7d 0a 5c 65 | 6e 64 7b 71 75 6f 74 65 |es..}.\e|nd{quote|
|00003810| 7d 0a 5c 65 6e 64 7b 71 | 75 6f 74 65 7d 0a 0a 57 |}.\end{q|uote}..W|
|00003820| 69 74 68 20 6d 75 6c 74 | 69 70 6c 65 20 69 6e 68 |ith mult|iple inh|
|00003830| 65 72 69 74 61 6e 63 65 | 2c 20 6f 72 64 65 72 69 |eritance|, orderi|
|00003840| 6e 67 20 69 73 20 68 61 | 72 64 65 72 2e 20 53 75 |ng is ha|rder. Su|
|00003850| 70 70 6f 73 65 20 77 65 | 20 68 61 76 65 0a 5c 62 |ppose we| have.\b|
|00003860| 65 67 69 6e 7b 73 63 68 | 65 6d 65 7d 0a 28 64 65 |egin{sch|eme}.(de|
|00003870| 66 69 6e 65 2d 63 6c 61 | 73 73 20 58 20 28 29 0a |fine-cla|ss X ().|
|00003880| 20 20 20 28 28 78 20 3a | 69 6e 69 74 66 6f 72 6d | ((x :|initform|
|00003890| 20 31 29 29 29 0a 0a 28 | 64 65 66 69 6e 65 2d 63 | 1)))..(|define-c|
|000038a0| 6c 61 73 73 20 59 20 28 | 29 0a 20 20 20 28 28 78 |lass Y (|). ((x|
|000038b0| 20 3a 69 6e 69 74 66 6f | 72 6d 20 32 29 29 29 0a | :initfo|rm 2))).|
|000038c0| 0a 28 64 65 66 69 6e 65 | 2d 63 6c 61 73 73 20 5a |.(define|-class Z|
|000038d0| 20 28 58 20 59 29 0a 20 | 20 20 28 2e 2e 2e 29 29 | (X Y). | (...))|
|000038e0| 0a 5c 65 6e 64 7b 73 63 | 68 65 6d 65 7d 0a 0a 49 |.\end{sc|heme}..I|
|000038f0| 6e 20 74 68 69 73 20 63 | 61 73 65 2c 20 74 68 65 |n this c|ase, the|
|00003900| 20 7b 5c 74 74 20 5a 7d | 20 63 6c 61 73 73 20 69 | {\tt Z}| class i|
|00003910| 73 20 6d 6f 72 65 20 73 | 70 65 63 69 66 69 63 20 |s more s|pecific |
|00003920| 74 68 61 6e 20 74 68 65 | 20 7b 5c 74 74 20 58 7d |than the| {\tt X}|
|00003930| 20 6f 72 20 0a 7b 5c 74 | 74 20 59 7d 20 63 6c 61 | or .{\t|t Y} cla|
|00003940| 73 73 20 66 6f 72 20 69 | 6e 73 74 61 6e 63 65 73 |ss for i|nstances|
|00003950| 20 6f 66 20 7b 5c 74 74 | 20 5a 7d 2e 20 48 6f 77 | of {\tt| Z}. How|
|00003960| 65 76 65 72 2c 20 74 68 | 65 20 7b 5c 74 74 20 3a |ever, th|e {\tt :|
|00003970| 69 6e 69 74 66 6f 72 6d | 7d 20 0a 73 70 65 63 69 |initform|} .speci|
|00003980| 66 69 65 64 20 69 6e 20 | 7b 5c 74 74 20 58 7d 20 |fied in |{\tt X} |
|00003990| 61 6e 64 20 7b 5c 74 74 | 20 59 7d 20 6c 65 61 64 |and {\tt| Y} lead|
|000039a0| 73 20 74 6f 20 61 20 70 | 72 6f 62 6c 65 6d 3a 20 |s to a p|roblem: |
|000039b0| 77 68 69 63 68 20 6f 6e | 65 0a 6f 76 65 72 72 69 |which on|e.overri|
|000039c0| 64 65 73 20 74 68 65 20 | 6f 74 68 65 72 3f 20 20 |des the |other? |
|000039d0| 54 68 65 20 72 75 6c 65 | 20 69 6e 20 7b 5c 73 74 |The rule| in {\st|
|000039e0| 6b 6c 6f 73 7d 2c 20 61 | 73 20 69 6e 20 43 4c 4f |klos}, a|s in CLO|
|000039f0| 53 2c 20 0a 69 73 20 74 | 68 61 74 20 74 68 65 20 |S, .is t|hat the |
|00003a00| 73 75 70 65 72 63 6c 61 | 73 73 65 73 20 6c 69 73 |supercla|sses lis|
|00003a10| 74 65 64 20 65 61 72 6c | 69 65 72 20 61 72 65 20 |ted earl|ier are |
|00003a20| 6d 6f 72 65 20 73 70 65 | 63 69 66 69 63 20 74 68 |more spe|cific th|
|00003a30| 61 6e 20 74 68 6f 73 65 | 20 6c 69 73 74 65 64 20 |an those| listed |
|00003a40| 6c 61 74 65 72 2e 20 0a | 53 6f 3a 0a 5c 62 65 67 |later. .|So:.\beg|
|00003a50| 69 6e 7b 71 75 6f 74 65 | 7d 0a 5c 62 65 67 69 6e |in{quote|}.\begin|
|00003a60| 7b 71 75 6f 74 65 7d 0a | 7b 5c 62 66 20 52 75 6c |{quote}.|{\bf Rul|
|00003a70| 65 20 32 3a 20 46 6f 72 | 20 61 20 67 69 76 65 6e |e 2: For| a given|
|00003a80| 20 63 6c 61 73 73 2c 20 | 73 75 70 65 72 63 6c 61 | class, |supercla|
|00003a90| 73 73 65 73 20 6c 69 73 | 74 65 64 20 65 61 72 6c |sses lis|ted earl|
|00003aa0| 69 65 72 20 61 72 65 20 | 6d 6f 72 65 0a 20 20 20 |ier are |more. |
|00003ab0| 20 20 20 20 20 73 70 65 | 63 69 66 69 63 20 74 68 | spe|cific th|
|00003ac0| 61 6e 20 74 68 6f 73 65 | 20 6c 69 73 74 65 64 20 |an those| listed |
|00003ad0| 6c 61 74 65 72 2e 0a 7d | 0a 5c 65 6e 64 7b 71 75 |later..}|.\end{qu|
|00003ae0| 6f 74 65 7d 0a 5c 65 6e | 64 7b 71 75 6f 74 65 7d |ote}.\en|d{quote}|
|00003af0| 0a 0a 54 68 65 73 65 20 | 72 75 6c 65 73 20 61 72 |..These |rules ar|
|00003b00| 65 20 75 73 65 64 20 74 | 6f 20 63 6f 6d 70 75 74 |e used t|o comput|
|00003b10| 65 20 61 20 6c 69 6e 65 | 61 72 20 6f 72 64 65 72 |e a line|ar order|
|00003b20| 20 66 6f 72 20 61 20 63 | 6c 61 73 73 20 61 6e 64 | for a c|lass and|
|00003b30| 20 61 6c 6c 20 69 74 73 | 0a 73 75 70 65 72 63 6c | all its|.supercl|
|00003b40| 61 73 73 65 73 2c 20 66 | 72 6f 6d 20 6d 6f 73 74 |asses, f|rom most|
|00003b50| 20 73 70 65 63 69 66 69 | 63 20 74 6f 20 6c 65 61 | specifi|c to lea|
|00003b60| 73 74 20 73 70 65 63 69 | 66 69 63 2e 20 20 54 68 |st speci|fic. Th|
|00003b70| 69 73 20 6f 72 64 65 72 | 20 69 73 20 63 61 6c 6c |is order| is call|
|00003b80| 65 64 20 74 68 65 0a 60 | 60 63 6c 61 73 73 20 70 |ed the.`|`class p|
|00003b90| 72 65 63 65 64 65 6e 63 | 65 20 6c 69 73 74 27 27 |recedenc|e list''|
|00003ba0| 20 6f 66 20 74 68 65 20 | 63 6c 61 73 73 2e 20 47 | of the |class. G|
|00003bb0| 69 76 65 6e 20 74 68 6f | 73 65 20 74 77 6f 20 72 |iven tho|se two r|
|00003bc0| 75 6c 65 73 2c 20 77 65 | 20 63 61 6e 20 63 6c 61 |ules, we| can cla|
|00003bd0| 69 6d 0a 74 68 61 74 20 | 74 68 65 20 69 6e 69 74 |im.that |the init|
|00003be0| 69 61 6c 20 66 6f 72 6d | 20 66 6f 72 20 74 68 65 |ial form| for the|
|00003bf0| 20 7b 5c 74 74 20 78 7d | 20 73 6c 6f 74 20 6f 66 | {\tt x}| slot of|
|00003c00| 20 70 72 65 76 69 6f 75 | 73 20 65 78 61 6d 70 6c | previou|s exampl|
|00003c10| 65 20 69 73 20 32 20 73 | 69 6e 63 65 20 74 68 65 |e is 2 s|ince the|
|00003c20| 0a 63 6c 61 73 73 20 7b | 5c 74 74 20 58 7d 20 69 |.class {|\tt X} i|
|00003c30| 73 20 70 6c 61 63 65 64 | 20 62 65 66 6f 72 65 20 |s placed| before |
|00003c40| 7b 5c 74 74 20 59 7d 20 | 69 6e 20 63 6c 61 73 73 |{\tt Y} |in class|
|00003c50| 20 70 72 65 63 65 64 65 | 6e 63 65 20 6c 69 73 74 | precede|nce list|
|00003c60| 20 6f 66 20 7b 5c 74 74 | 20 5a 7d 2e 0a 0a 54 68 | of {\tt| Z}...Th|
|00003c70| 69 73 20 74 77 6f 20 72 | 75 6c 65 73 20 61 72 65 |is two r|ules are|
|00003c80| 20 6e 6f 74 20 61 6c 77 | 61 79 73 20 65 6e 6f 75 | not alw|ays enou|
|00003c90| 67 68 20 74 6f 20 64 65 | 74 65 72 6d 69 6e 65 20 |gh to de|termine |
|00003ca0| 61 20 75 6e 69 71 75 65 | 20 6f 72 64 65 72 2c 20 |a unique| order, |
|00003cb0| 68 6f 77 65 76 65 72 2c | 20 62 75 74 0a 74 68 65 |however,| but.the|
|00003cc0| 79 20 67 69 76 65 20 61 | 6e 20 69 64 65 61 20 6f |y give a|n idea o|
|00003cd0| 66 20 68 6f 77 20 74 68 | 69 6e 67 73 20 77 6f 72 |f how th|ings wor|
|00003ce0| 6b 2e 20 7b 5c 73 74 6b | 6c 6f 73 7d 20 61 6c 67 |k. {\stk|los} alg|
|00003cf0| 6f 72 69 74 68 6d 20 66 | 6f 72 20 63 61 6c 63 75 |orithm f|or calcu|
|00003d00| 6c 61 74 69 6e 67 20 74 | 68 65 0a 70 72 65 63 65 |lating t|he.prece|
|00003d10| 64 65 6e 63 65 20 6c 69 | 73 74 20 69 73 20 61 20 |dence li|st is a |
|00003d20| 6c 69 74 74 6c 65 20 73 | 69 6d 70 6c 65 72 20 74 |little s|impler t|
|00003d30| 68 61 6e 20 74 68 65 20 | 43 4c 4f 53 20 6f 6e 65 |han the |CLOS one|
|00003d40| 20 64 65 73 63 72 69 62 | 65 64 20 69 6e 0a 5c 63 | describ|ed in.\c|
|00003d50| 69 74 65 7b 41 4d 4f 50 | 7d 20 66 6f 72 20 62 72 |ite{AMOP|} for br|
|00003d60| 65 61 6b 69 6e 67 20 74 | 69 65 73 2e 20 43 6f 6e |eaking t|ies. Con|
|00003d70| 73 65 71 75 65 6e 74 6c | 79 20 74 68 65 20 63 61 |sequentl|y the ca|
|00003d80| 6c 63 75 6c 61 74 65 64 | 20 63 6c 61 73 73 20 70 |lculated| class p|
|00003d90| 72 65 63 65 64 65 6e 63 | 65 0a 6c 69 73 74 20 63 |recedenc|e.list c|
|00003da0| 6f 75 6c 64 20 62 65 20 | 64 69 66 66 65 72 65 6e |ould be |differen|
|00003db0| 74 2e 20 54 61 6b 69 6e | 67 20 74 68 65 20 7b 5c |t. Takin|g the {\|
|00003dc0| 74 74 20 46 7d 20 63 6c | 61 73 73 20 73 68 6f 77 |tt F} cl|ass show|
|00003dd0| 6e 20 69 6e 20 46 69 67 | 75 72 65 7e 31 2c 20 74 |n in Fig|ure~1, t|
|00003de0| 68 65 20 7b 5c 73 74 6b | 6c 6f 73 7d 20 0a 63 61 |he {\stk|los} .ca|
|00003df0| 6c 63 75 6c 61 74 65 64 | 20 63 6c 61 73 73 20 70 |lculated| class p|
|00003e00| 72 65 63 65 64 65 6e 63 | 65 20 6c 69 73 74 20 69 |recedenc|e list i|
|00003e10| 73 0a 0a 5c 62 65 67 69 | 6e 7b 71 75 6f 74 65 7d |s..\begi|n{quote}|
|00003e20| 0a 7b 5c 74 74 0a 28 66 | 20 64 20 65 20 61 20 62 |.{\tt.(f| d e a b|
|00003e30| 20 63 20 3c 6f 62 6a 65 | 63 74 3e 20 3c 74 6f 70 | c <obje|ct> <top|
|00003e40| 3e 29 0a 7d 0a 5c 65 6e | 64 7b 71 75 6f 74 65 7d |>).}.\en|d{quote}|
|00003e50| 0a 77 68 65 72 65 61 73 | 20 69 74 20 77 6f 75 6c |.whereas| it woul|
|00003e60| 64 20 62 65 20 74 68 65 | 20 66 6f 6c 6c 6f 77 69 |d be the| followi|
|00003e70| 6e 67 20 6c 69 73 74 20 | 77 69 74 68 20 61 20 43 |ng list |with a C|
|00003e80| 4c 4f 53 2d 6c 69 6b 65 | 20 61 6c 67 6f 72 69 74 |LOS-like| algorit|
|00003e90| 68 6d 3a 0a 5c 62 65 67 | 69 6e 7b 71 75 6f 74 65 |hm:.\beg|in{quote|
|00003ea0| 7d 0a 7b 5c 74 74 0a 28 | 66 20 64 20 65 20 61 20 |}.{\tt.(|f d e a |
|00003eb0| 63 20 62 20 3c 6f 62 6a | 65 63 74 3e 20 3c 74 6f |c b <obj|ect> <to|
|00003ec0| 70 3e 29 0a 7d 0a 5c 65 | 6e 64 7b 71 75 6f 74 65 |p>).}.\e|nd{quote|
|00003ed0| 7d 0a 0a 48 6f 77 65 76 | 65 72 2c 20 69 74 20 69 |}..Howev|er, it i|
|00003ee0| 73 20 75 73 75 61 6c 6c | 79 20 63 6f 6e 73 69 64 |s usuall|y consid|
|00003ef0| 65 72 65 64 20 61 20 62 | 61 64 20 69 64 65 61 20 |ered a b|ad idea |
|00003f00| 66 6f 72 20 70 72 6f 67 | 72 61 6d 6d 65 72 73 20 |for prog|rammers |
|00003f10| 74 6f 20 72 65 6c 79 20 | 6f 6e 0a 65 78 61 63 74 |to rely |on.exact|
|00003f20| 6c 79 20 77 68 61 74 20 | 74 68 65 20 6f 72 64 65 |ly what |the orde|
|00003f30| 72 20 69 73 2e 20 20 49 | 66 20 74 68 65 20 6f 72 |r is. I|f the or|
|00003f40| 64 65 72 20 66 6f 72 20 | 73 6f 6d 65 20 73 75 70 |der for |some sup|
|00003f50| 65 72 63 6c 61 73 73 65 | 73 20 69 73 20 69 6d 70 |erclasse|s is imp|
|00003f60| 6f 72 74 61 6e 74 2c 0a | 69 74 20 63 61 6e 20 62 |ortant,.|it can b|
|00003f70| 65 20 65 78 70 72 65 73 | 73 65 64 20 64 69 72 65 |e expres|sed dire|
|00003f80| 63 74 6c 79 20 69 6e 20 | 74 68 65 20 63 6c 61 73 |ctly in |the clas|
|00003f90| 73 20 64 65 66 69 6e 69 | 74 69 6f 6e 2e 0a 0a 54 |s defini|tion...T|
|00003fa0| 68 65 20 70 72 65 63 65 | 64 65 6e 63 65 20 6c 69 |he prece|dence li|
|00003fb0| 73 74 20 6f 66 20 61 20 | 63 6c 61 73 73 20 63 61 |st of a |class ca|
|00003fc0| 6e 20 62 65 20 6f 62 74 | 61 69 6e 65 64 20 62 79 |n be obt|ained by|
|00003fd0| 20 74 68 65 20 66 75 6e | 63 74 69 6f 6e 20 0a 5c | the fun|ction .\|
|00003fe0| 69 64 65 7b 63 6c 61 73 | 73 2d 70 72 65 63 65 64 |ide{clas|s-preced|
|00003ff0| 65 6e 63 65 2d 6c 69 73 | 74 7d 2e 20 54 68 69 73 |ence-lis|t}. This|
|00004000| 20 66 75 6e 63 74 69 6f | 6e 20 72 65 74 75 72 6e | functio|n return|
|00004010| 73 20 61 20 6f 72 64 65 | 72 65 64 20 0a 6c 69 73 |s a orde|red .lis|
|00004020| 74 20 77 68 6f 73 65 20 | 66 69 72 73 74 20 65 6c |t whose |first el|
|00004030| 65 6d 65 6e 74 20 69 73 | 20 74 68 65 20 6d 6f 73 |ement is| the mos|
|00004040| 74 20 73 70 65 63 69 66 | 69 63 20 63 6c 61 73 73 |t specif|ic class|
|00004050| 2e 20 46 6f 72 20 69 6e | 73 74 61 6e 63 65 2c 20 |. For in|stance, |
|00004060| 0a 5c 62 65 67 69 6e 7b | 73 63 68 65 6d 65 7d 0a |.\begin{|scheme}.|
|00004070| 28 63 6c 61 73 73 2d 70 | 72 65 63 65 64 65 6e 63 |(class-p|recedenc|
|00004080| 65 2d 6c 69 73 74 20 42 | 29 20 5c 6c 65 76 20 28 |e-list B|) \lev (|
|00004090| 5c 73 68 61 72 70 73 69 | 67 6e 5b 3c 63 6c 61 73 |\sharpsi|gn[<clas|
|000040a0| 73 3e 20 31 32 61 32 34 | 38 5d 20 5c 73 68 61 72 |s> 12a24|8] \shar|
|000040b0| 70 73 69 67 6e 5b 3c 63 | 6c 61 73 73 3e 20 31 30 |psign[<c|lass> 10|
|000040c0| 37 34 65 38 5d 20 5c 73 | 68 61 72 70 73 69 67 6e |74e8] \s|harpsign|
|000040d0| 5b 3c 63 6c 61 73 73 3e | 20 31 30 37 34 39 38 5d |[<class>| 107498]|
|000040e0| 29 0a 5c 65 6e 64 7b 73 | 63 68 65 6d 65 7d 0a 48 |).\end{s|cheme}.H|
|000040f0| 6f 77 65 76 65 72 2c 20 | 74 68 69 73 20 72 65 73 |owever, |this res|
|00004100| 75 6c 74 20 69 73 20 6e | 6f 74 20 74 6f 6f 20 6d |ult is n|ot too m|
|00004110| 75 63 68 20 72 65 61 64 | 61 62 6c 65 3b 20 75 73 |uch read|able; us|
|00004120| 69 6e 67 20 74 68 65 20 | 66 75 6e 63 74 69 6f 6e |ing the |function|
|00004130| 20 63 6c 61 73 73 2d 6e | 61 6d 65 0a 79 69 65 6c | class-n|ame.yiel|
|00004140| 64 73 20 61 20 63 6c 65 | 61 72 65 72 20 72 65 73 |ds a cle|arer res|
|00004150| 75 6c 74 3a 0a 5c 62 65 | 67 69 6e 7b 73 63 68 65 |ult:.\be|gin{sche|
|00004160| 6d 65 7d 0a 28 6d 61 70 | 20 63 6c 61 73 73 2d 6e |me}.(map| class-n|
|00004170| 61 6d 65 20 28 63 6c 61 | 73 73 2d 70 72 65 63 65 |ame (cla|ss-prece|
|00004180| 64 65 6e 63 65 2d 6c 69 | 73 74 20 42 29 29 20 5c |dence-li|st B)) \|
|00004190| 6c 65 76 20 28 62 20 3c | 6f 62 6a 65 63 74 3e 20 |lev (b <|object> |
|000041a0| 3c 74 6f 70 3e 29 0a 5c | 65 6e 64 7b 73 63 68 65 |<top>).\|end{sche|
|000041b0| 6d 65 7d 0a 0a 5c 73 65 | 63 74 69 6f 6e 7b 47 65 |me}..\se|ction{Ge|
|000041c0| 6e 65 72 69 63 20 66 75 | 6e 63 74 69 6f 6e 73 7d |neric fu|nctions}|
|000041d0| 0a 0a 5c 73 75 62 73 65 | 63 74 69 6f 6e 7b 47 65 |..\subse|ction{Ge|
|000041e0| 6e 65 72 69 63 20 66 75 | 6e 63 74 69 6f 6e 73 20 |neric fu|nctions |
|000041f0| 61 6e 64 20 6d 65 74 68 | 6f 64 73 7d 0a 0a 5c 6c |and meth|ods}..\l|
|00004200| 61 62 65 6c 7b 67 66 2d | 6e 2d 6d 65 74 68 6f 64 |abel{gf-|n-method|
|00004210| 73 7d 0a 4e 65 69 74 68 | 65 72 20 7b 5c 73 74 6b |s}.Neith|er {\stk|
|00004220| 6c 6f 73 7d 20 6e 6f 72 | 20 43 4c 4f 53 20 75 73 |los} nor| CLOS us|
|00004230| 65 20 74 68 65 20 6d 65 | 73 73 61 67 65 20 6d 65 |e the me|ssage me|
|00004240| 63 68 61 6e 69 73 6d 20 | 66 6f 72 20 6d 65 74 68 |chanism |for meth|
|00004250| 6f 64 73 20 61 73 0a 6d | 6f 73 74 20 4f 62 6a 65 |ods as.m|ost Obje|
|00004260| 63 74 20 4f 72 69 65 6e | 74 65 64 20 6c 61 6e 67 |ct Orien|ted lang|
|00004270| 75 61 67 65 20 64 6f 2e | 20 49 6e 73 74 65 61 64 |uage do.| Instead|
|00004280| 2c 20 74 68 65 79 20 75 | 73 65 20 74 68 65 20 6e |, they u|se the n|
|00004290| 6f 74 69 6f 6e 20 6f 66 | 0a 67 65 6e 65 72 69 63 |otion of|.generic|
|000042a0| 20 66 75 6e 63 74 69 6f | 6e 2e 20 20 41 20 67 65 | functio|n. A ge|
|000042b0| 6e 65 72 69 63 20 66 75 | 6e 63 74 69 6f 6e 20 63 |neric fu|nction c|
|000042c0| 61 6e 20 62 65 20 73 65 | 65 6e 20 61 73 20 61 20 |an be se|en as a |
|000042d0| 6d 65 74 68 6f 64 73 0a | 60 60 74 61 6e 6b 65 72 |methods.|``tanker|
|000042e0| 27 27 2e 20 57 68 65 6e | 20 74 68 65 20 65 76 61 |''. When| the eva|
|000042f0| 6c 75 61 74 6f 72 20 72 | 65 71 75 65 73 74 64 20 |luator r|equestd |
|00004300| 74 68 65 20 61 70 70 6c | 69 63 61 74 69 6f 6e 20 |the appl|ication |
|00004310| 6f 66 20 61 20 67 65 6e | 65 72 69 63 0a 66 75 6e |of a gen|eric.fun|
|00004320| 63 74 69 6f 6e 2c 20 61 | 6c 6c 20 74 68 65 20 6d |ction, a|ll the m|
|00004330| 65 74 68 6f 64 73 20 6f | 66 20 74 68 69 73 20 67 |ethods o|f this g|
|00004340| 65 6e 65 72 69 63 20 66 | 75 6e 63 74 69 6f 6e 20 |eneric f|unction |
|00004350| 77 69 6c 6c 20 62 65 20 | 67 72 61 62 62 65 64 20 |will be |grabbed |
|00004360| 61 6e 64 0a 74 68 65 20 | 6d 6f 73 74 20 73 70 65 |and.the |most spe|
|00004370| 63 69 66 69 63 20 61 6d | 6f 6e 67 20 74 68 65 6d |cific am|ong them|
|00004380| 20 77 69 6c 6c 20 62 65 | 20 61 70 70 6c 69 65 64 | will be| applied|
|00004390| 2e 20 57 65 20 73 61 79 | 20 74 68 61 74 20 61 20 |. We say| that a |
|000043a0| 6d 65 74 68 6f 64 0a 7b | 5c 65 6d 20 4d 7d 20 69 |method.{|\em M} i|
|000043b0| 73 20 7b 5c 65 6d 20 6d | 6f 72 65 20 73 70 65 63 |s {\em m|ore spec|
|000043c0| 69 66 69 63 7d 20 74 68 | 61 6e 20 61 20 6d 65 74 |ific} th|an a met|
|000043d0| 68 6f 64 20 7b 5c 65 6d | 20 4d 27 7d 20 69 66 20 |hod {\em| M'} if |
|000043e0| 74 68 65 20 63 6c 61 73 | 73 20 6f 66 0a 69 74 73 |the clas|s of.its|
|000043f0| 20 70 61 72 61 6d 65 74 | 65 72 73 20 61 72 65 20 | paramet|ers are |
|00004400| 6d 6f 72 65 20 73 70 65 | 63 69 66 69 63 20 74 68 |more spe|cific th|
|00004410| 61 6e 20 74 68 65 20 7b | 5c 65 6d 20 4d 27 7d 20 |an the {|\em M'} |
|00004420| 6f 6e 65 73 2e 20 20 54 | 6f 20 62 65 20 6d 6f 72 |ones. T|o be mor|
|00004430| 65 0a 70 72 65 63 69 73 | 65 2c 20 77 68 65 6e 20 |e.precis|e, when |
|00004440| 61 20 67 65 6e 65 72 69 | 63 20 66 75 6e 74 69 6f |a generi|c funtio|
|00004450| 6e 20 6d 75 73 74 20 62 | 65 20 60 60 63 61 6c 6c |n must b|e ``call|
|00004460| 65 64 27 27 20 74 68 65 | 20 73 79 73 74 65 6d 20 |ed'' the| system |
|00004470| 77 69 6c 6c 0a 0a 5c 62 | 65 67 69 6e 7b 65 6e 75 |will..\b|egin{enu|
|00004480| 6d 65 72 61 74 65 7d 0a | 5c 69 74 65 6d 20 73 65 |merate}.|\item se|
|00004490| 61 72 63 68 20 61 6d 6f | 6e 67 20 61 6c 6c 20 74 |arch amo|ng all t|
|000044a0| 68 65 20 67 65 6e 65 72 | 69 63 20 66 75 6e 63 74 |he gener|ic funct|
|000044b0| 69 6f 6e 20 74 68 6f 73 | 65 20 77 68 69 63 68 20 |ion thos|e which |
|000044c0| 61 72 65 20 61 70 70 6c | 69 63 61 62 6c 65 0a 5c |are appl|icable.\|
|000044d0| 69 74 65 6d 20 73 6f 72 | 74 20 74 68 65 20 6c 69 |item sor|t the li|
|000044e0| 73 74 20 6f 66 20 61 70 | 70 6c 69 63 61 62 6c 65 |st of ap|plicable|
|000044f0| 20 6d 65 74 68 6f 64 73 | 20 69 6e 20 74 68 65 20 | methods| in the |
|00004500| 60 60 6d 6f 73 74 20 73 | 70 65 63 69 66 69 63 27 |``most s|pecific'|
|00004510| 27 20 6f 72 64 65 72 0a | 5c 69 74 65 6d 20 63 61 |' order.|\item ca|
|00004520| 6c 6c 20 74 68 65 20 6d | 6f 73 74 20 73 70 65 63 |ll the m|ost spec|
|00004530| 69 66 69 63 20 6d 65 74 | 68 6f 64 20 6f 66 20 74 |ific met|hod of t|
|00004540| 68 69 73 20 6c 69 73 74 | 20 28 69 2e 65 2e 20 74 |his list| (i.e. t|
|00004550| 68 65 20 66 69 72 73 74 | 20 6d 65 74 68 6f 64 20 |he first| method |
|00004560| 6f 66 20 0a 74 68 65 20 | 73 6f 72 74 65 64 20 6d |of .the |sorted m|
|00004570| 65 74 68 6f 64 73 20 6c | 69 73 74 29 2e 0a 5c 65 |ethods l|ist)..\e|
|00004580| 6e 64 7b 65 6e 75 6d 65 | 72 61 74 65 7d 0a 0a 54 |nd{enume|rate}..T|
|00004590| 68 65 20 64 65 66 69 6e | 69 74 69 6f 6e 20 6f 66 |he defin|ition of|
|000045a0| 20 61 20 67 65 6e 65 72 | 69 63 20 66 75 6e 63 74 | a gener|ic funct|
|000045b0| 69 6f 6e 20 69 73 20 64 | 6f 6e 65 20 77 69 74 68 |ion is d|one with|
|000045c0| 20 74 68 65 20 5c 69 64 | 65 7b 64 65 66 69 6e 65 | the \id|e{define|
|000045d0| 2d 67 65 6e 65 72 69 63 | 7d 0a 6d 61 63 72 6f 2e |-generic|}.macro.|
|000045e0| 20 44 65 66 69 6e 69 74 | 69 6f 6e 20 6f 66 20 61 | Definit|ion of a|
|000045f0| 20 6e 65 77 20 6d 65 74 | 68 6f 64 20 69 73 20 64 | new met|hod is d|
|00004600| 6f 6e 65 20 77 69 74 68 | 20 74 68 65 20 5c 69 64 |one with| the \id|
|00004610| 65 7b 64 65 66 69 6e 65 | 2d 6d 65 74 68 6f 64 7d |e{define|-method}|
|00004620| 20 6d 61 63 72 6f 2e 0a | 4e 6f 74 65 20 74 68 61 | macro..|Note tha|
|00004630| 74 20 5c 69 64 65 7b 64 | 65 66 69 6e 65 2d 6d 65 |t \ide{d|efine-me|
|00004640| 74 68 6f 64 7d 20 61 75 | 74 6f 6d 61 74 69 63 61 |thod} au|tomatica|
|00004650| 6c 6c 79 20 64 65 66 69 | 6e 65 73 20 74 68 65 20 |lly defi|nes the |
|00004660| 67 65 6e 65 72 69 63 20 | 66 75 6e 63 74 69 6f 6e |generic |function|
|00004670| 20 69 66 20 69 74 0a 68 | 61 73 20 6e 6f 74 20 62 | if it.h|as not b|
|00004680| 65 65 6e 20 64 65 66 69 | 6e 65 64 20 62 65 66 6f |een defi|ned befo|
|00004690| 72 65 2e 20 43 6f 6e 73 | 65 71 75 65 6e 74 6c 79 |re. Cons|equently|
|000046a0| 2c 20 6d 6f 73 74 20 6f | 66 20 74 68 65 20 74 69 |, most o|f the ti|
|000046b0| 6d 65 2c 20 74 68 65 0a | 5c 69 64 65 7b 64 65 66 |me, the.|\ide{def|
|000046c0| 69 6e 65 2d 67 65 6e 65 | 72 69 63 7d 20 6e 65 65 |ine-gene|ric} nee|
|000046d0| 64 73 20 6e 6f 74 20 62 | 65 20 75 73 65 64 2e 0a |ds not b|e used..|
|000046e0| 0a 43 6f 6e 73 69 64 65 | 72 20 74 68 65 20 66 6f |.Conside|r the fo|
|000046f0| 6c 6c 6f 77 69 6e 67 20 | 64 65 66 69 6e 69 74 69 |llowing |definiti|
|00004700| 6f 6e 73 3a 0a 5c 62 65 | 67 69 6e 7b 73 63 68 65 |ons:.\be|gin{sche|
|00004710| 6d 65 7d 0a 28 64 65 66 | 69 6e 65 2d 67 65 6e 65 |me}.(def|ine-gene|
|00004720| 72 69 63 20 4d 29 0a 28 | 64 65 66 69 6e 65 2d 6d |ric M).(|define-m|
|00004730| 65 74 68 6f 64 20 4d 28 | 28 61 20 3c 69 6e 74 65 |ethod M(|(a <inte|
|00004740| 67 65 72 3e 29 20 62 29 | 20 27 69 6e 74 65 67 65 |ger>) b)| 'intege|
|00004750| 72 29 0a 28 64 65 66 69 | 6e 65 2d 6d 65 74 68 6f |r).(defi|ne-metho|
|00004760| 64 20 4d 28 28 61 20 3c | 72 65 61 6c 3e 29 20 62 |d M((a <|real>) b|
|00004770| 29 20 27 72 65 61 6c 29 | 0a 28 64 65 66 69 6e 65 |) 'real)|.(define|
|00004780| 2d 6d 65 74 68 6f 64 20 | 4d 28 61 20 62 29 20 27 |-method |M(a b) '|
|00004790| 74 6f 70 29 0a 5c 65 6e | 64 7b 73 63 68 65 6d 65 |top).\en|d{scheme|
|000047a0| 7d 0a 0a 54 68 65 20 5c | 69 64 65 7b 64 65 66 69 |}..The \|ide{defi|
|000047b0| 6e 65 2d 67 65 6e 65 72 | 69 63 7d 20 63 61 6c 6c |ne-gener|ic} call|
|000047c0| 20 64 65 66 69 6e 65 73 | 20 7b 5c 74 74 20 4d 7d | defines| {\tt M}|
|000047d0| 20 61 73 20 61 20 67 65 | 6e 65 72 69 63 0a 66 75 | as a ge|neric.fu|
|000047e0| 6e 63 74 69 6f 6e 2e 20 | 4e 6f 74 65 20 74 68 61 |nction. |Note tha|
|000047f0| 74 20 74 68 65 20 73 69 | 67 6e 61 74 75 72 65 20 |t the si|gnature |
|00004800| 6f 66 20 74 68 65 20 67 | 65 6e 65 72 69 63 20 66 |of the g|eneric f|
|00004810| 75 6e 63 74 69 6f 6e 20 | 69 73 20 6e 6f 74 20 67 |unction |is not g|
|00004820| 69 76 65 6e 0a 75 70 6f | 6e 20 64 65 66 69 6e 69 |iven.upo|n defini|
|00004830| 74 69 6f 6e 2c 20 63 6f | 6e 74 72 61 72 69 6c 79 |tion, co|ntrarily|
|00004840| 20 74 6f 20 43 4c 4f 53 | 2e 20 54 68 69 73 20 77 | to CLOS|. This w|
|00004850| 69 6c 6c 20 70 65 72 6d | 69 74 20 6d 65 74 68 6f |ill perm|it metho|
|00004860| 64 73 20 77 69 74 68 0a | 64 69 66 66 65 72 65 6e |ds with.|differen|
|00004870| 74 20 73 69 67 6e 61 74 | 75 72 65 73 20 66 6f 72 |t signat|ures for|
|00004880| 20 61 20 67 69 76 65 6e | 20 67 65 6e 65 72 69 63 | a given| generic|
|00004890| 20 66 75 6e 63 74 69 6f | 6e 2c 20 61 73 20 77 65 | functio|n, as we|
|000048a0| 20 73 68 61 6c 6c 20 73 | 65 65 0a 6c 61 74 65 72 | shall s|ee.later|
|000048b0| 2e 20 54 68 65 20 74 68 | 72 65 65 20 6e 65 78 74 |. The th|ree next|
|000048c0| 20 6c 69 6e 65 73 20 64 | 65 66 69 6e 65 20 6d 65 | lines d|efine me|
|000048d0| 74 68 6f 64 73 20 66 6f | 72 20 74 68 65 20 7b 5c |thods fo|r the {\|
|000048e0| 74 74 20 4d 7d 20 67 65 | 6e 65 72 69 63 0a 66 75 |tt M} ge|neric.fu|
|000048f0| 6e 63 74 69 6f 6e 2e 20 | 45 61 63 68 20 6d 65 74 |nction. |Each met|
|00004900| 68 6f 64 20 75 73 65 73 | 20 61 20 73 65 71 75 65 |hod uses| a seque|
|00004910| 6e 63 65 20 6f 66 20 7b | 5c 65 6d 20 70 61 72 61 |nce of {|\em para|
|00004920| 6d 65 74 65 72 20 73 70 | 65 63 69 61 6c 69 7a 65 |meter sp|ecialize|
|00004930| 72 73 7d 0a 74 68 61 74 | 20 73 70 65 63 69 66 79 |rs}.that| specify|
|00004940| 20 77 68 65 6e 20 74 68 | 65 20 67 69 76 65 6e 20 | when th|e given |
|00004950| 6d 65 74 68 6f 64 20 69 | 73 20 61 70 70 6c 69 63 |method i|s applic|
|00004960| 61 62 6c 65 2e 20 41 20 | 73 70 65 63 69 61 6c 69 |able. A |speciali|
|00004970| 7a 65 72 0a 70 65 72 6d | 69 74 73 20 74 6f 20 69 |zer.perm|its to i|
|00004980| 6e 64 69 63 61 74 65 20 | 74 68 65 20 63 6c 61 73 |ndicate |the clas|
|00004990| 73 20 61 20 70 61 72 61 | 6d 65 74 65 72 20 6d 75 |s a para|meter mu|
|000049a0| 73 74 20 62 65 6c 6f 6e | 67 20 74 6f 20 28 64 69 |st belon|g to (di|
|000049b0| 72 65 63 74 6c 79 20 6f | 72 0a 69 6e 64 69 72 65 |rectly o|r.indire|
|000049c0| 63 74 6c 79 29 20 74 6f | 20 62 65 20 61 70 70 6c |ctly) to| be appl|
|000049d0| 69 63 61 62 6c 65 2e 20 | 49 66 20 6e 6f 20 73 70 |icable. |If no sp|
|000049e0| 65 63 69 6c 69 61 7a 65 | 72 20 69 73 20 67 69 76 |eciliaze|r is giv|
|000049f0| 65 6e 2c 20 74 68 65 20 | 73 79 73 74 65 6d 0a 64 |en, the |system.d|
|00004a00| 65 66 61 75 6c 74 73 20 | 69 74 20 74 6f 20 5c 69 |efaults |it to \i|
|00004a10| 64 65 7b 3c 74 6f 70 3e | 7d 2e 20 54 68 75 73 2c |de{<top>|}. Thus,|
|00004a20| 20 74 68 65 20 66 69 72 | 73 74 20 6d 65 74 68 6f | the fir|st metho|
|00004a30| 64 20 64 65 66 69 6e 69 | 74 69 6f 6e 0a 69 73 20 |d defini|tion.is |
|00004a40| 65 71 75 69 76 61 6c 65 | 6e 74 20 74 6f 0a 0a 5c |equivale|nt to..\|
|00004a50| 62 65 67 69 6e 7b 73 63 | 68 65 6d 65 7d 0a 28 64 |begin{sc|heme}.(d|
|00004a60| 65 66 69 6e 65 2d 6d 65 | 74 68 6f 64 20 4d 28 28 |efine-me|thod M((|
|00004a70| 61 20 3c 69 6e 74 65 67 | 65 72 3e 29 20 28 62 20 |a <integ|er>) (b |
|00004a80| 3c 74 6f 70 3e 29 29 20 | 27 69 6e 74 65 67 65 72 |<top>)) |'integer|
|00004a90| 29 0a 5c 65 6e 64 7b 73 | 63 68 65 6d 65 7d 0a 0a |).\end{s|cheme}..|
|00004aa0| 4e 6f 77 2c 20 6c 65 74 | 20 75 73 20 6c 6f 6f 6b |Now, let| us look|
|00004ab0| 20 61 74 20 73 6f 6d 65 | 20 70 6f 73 73 69 62 6c | at some| possibl|
|00004ac0| 65 20 63 61 6c 6c 73 20 | 74 6f 20 67 65 6e 65 72 |e calls |to gener|
|00004ad0| 69 63 20 66 75 6e 63 74 | 69 6f 6e 20 7b 5c 74 74 |ic funct|ion {\tt|
|00004ae0| 20 4d 7d 3a 0a 5c 62 65 | 67 69 6e 7b 73 63 68 65 | M}:.\be|gin{sche|
|00004af0| 6d 65 7d 0a 28 4d 20 32 | 20 33 29 20 5c 6c 65 76 |me}.(M 2| 3) \lev|
|00004b00| 20 69 6e 74 65 67 65 72 | 0a 28 4d 20 32 20 5c 73 | integer|.(M 2 \s|
|00004b10| 63 68 74 72 75 65 29 20 | 5c 6c 65 76 20 69 6e 74 |chtrue) |\lev int|
|00004b20| 65 67 65 72 0a 28 4d 20 | 31 2e 32 20 27 61 29 20 |eger.(M |1.2 'a) |
|00004b30| 5c 6c 65 76 20 72 65 61 | 6c 0a 28 4d 20 7b 5c 73 |\lev rea|l.(M {\s|
|00004b40| 68 61 72 70 73 69 67 6e | 7d 33 20 27 61 29 20 5c |harpsign|}3 'a) \|
|00004b50| 6c 65 76 20 72 65 61 6c | 0a 28 4d 20 7b 5c 73 63 |lev real|.(M {\sc|
|00004b60| 68 74 72 75 65 7d 20 7b | 5c 73 63 68 66 61 6c 73 |htrue} {|\schfals|
|00004b70| 65 7d 29 20 5c 6c 65 76 | 20 74 6f 70 0a 28 4d 20 |e}) \lev| top.(M |
|00004b80| 31 20 32 20 33 29 20 5c | 6c 65 76 20 65 72 72 6f |1 2 3) \|lev erro|
|00004b90| 72 20 28 73 69 6e 63 65 | 20 6e 6f 20 6d 65 74 68 |r (since| no meth|
|00004ba0| 6f 64 20 65 78 69 73 74 | 73 20 66 6f 72 20 33 20 |od exist|s for 3 |
|00004bb0| 70 61 72 61 6d 65 74 65 | 72 73 29 0a 5c 65 6e 64 |paramete|rs).\end|
|00004bc0| 7b 73 63 68 65 6d 65 7d | 0a 0a 54 68 65 20 70 72 |{scheme}|..The pr|
|00004bd0| 65 63 65 64 69 6e 67 20 | 6d 65 74 68 6f 64 73 20 |eceding |methods |
|00004be0| 75 73 65 20 6f 6e 6c 79 | 20 6f 6e 65 20 73 70 65 |use only| one spe|
|00004bf0| 63 69 61 6c 69 7a 65 72 | 20 70 65 72 20 70 61 72 |cializer| per par|
|00004c00| 61 6d 65 74 65 72 20 6c | 69 73 74 2e 20 4f 66 20 |ameter l|ist. Of |
|00004c10| 63 6f 75 72 73 65 2c 20 | 0a 65 61 63 68 20 70 61 |course, |.each pa|
|00004c20| 72 61 6d 65 74 65 72 20 | 63 61 6e 20 75 73 65 20 |rameter |can use |
|00004c30| 61 20 73 70 65 63 69 61 | 6c 69 7a 65 72 2e 20 49 |a specia|lizer. I|
|00004c40| 6e 20 74 68 69 73 20 63 | 61 73 65 2c 20 74 68 65 |n this c|ase, the|
|00004c50| 20 70 61 72 61 6d 65 74 | 65 72 20 6c 69 73 74 20 | paramet|er list |
|00004c60| 69 73 20 73 63 61 6e 6e | 65 64 20 0a 66 72 6f 6d |is scann|ed .from|
|00004c70| 20 6c 65 66 74 20 74 6f | 20 72 69 67 68 74 20 74 | left to| right t|
|00004c80| 6f 20 64 65 74 65 72 6d | 69 6e 65 20 74 68 65 20 |o determ|ine the |
|00004c90| 61 70 70 6c 69 63 61 62 | 69 6c 69 74 79 20 6f 66 |applicab|ility of|
|00004ca0| 20 61 20 6d 65 74 68 6f | 64 2e 20 53 75 70 70 6f | a metho|d. Suppo|
|00004cb0| 73 65 20 77 65 20 64 65 | 63 6c 61 72 65 0a 6e 6f |se we de|clare.no|
|00004cc0| 77 0a 5c 62 65 67 69 6e | 7b 73 63 68 65 6d 65 7d |w.\begin|{scheme}|
|00004cd0| 0a 28 64 65 66 69 6e 65 | 2d 6d 65 74 68 6f 64 20 |.(define|-method |
|00004ce0| 4d 20 28 28 61 20 3c 69 | 6e 74 65 67 65 72 3e 29 |M ((a <i|nteger>)|
|00004cf0| 20 28 62 20 3c 6e 75 6d | 62 65 72 3e 29 29 20 27 | (b <num|ber>)) '|
|00004d00| 69 6e 74 65 67 65 72 2d | 6e 75 6d 62 65 72 29 0a |integer-|number).|
|00004d10| 28 64 65 66 69 6e 65 2d | 6d 65 74 68 6f 64 20 4d |(define-|method M|
|00004d20| 20 28 28 61 20 3c 69 6e | 74 65 67 65 72 3e 29 20 | ((a <in|teger>) |
|00004d30| 28 62 20 3c 72 65 61 6c | 3e 29 29 20 20 20 27 69 |(b <real|>)) 'i|
|00004d40| 6e 74 65 67 65 72 2d 72 | 65 61 6c 29 0a 28 64 65 |nteger-r|eal).(de|
|00004d50| 66 69 6e 65 2d 6d 65 74 | 68 6f 64 20 4d 20 28 61 |fine-met|hod M (a|
|00004d60| 20 28 62 20 3c 6e 75 6d | 62 65 72 3e 29 29 20 27 | (b <num|ber>)) '|
|00004d70| 74 6f 70 2d 6e 75 6d 62 | 65 72 29 0a 5c 65 6e 64 |top-numb|er).\end|
|00004d80| 7b 73 63 68 65 6d 65 7d | 0a 0a 49 6e 20 74 68 69 |{scheme}|..In thi|
|00004d90| 73 20 63 61 73 65 2c 20 | 0a 5c 62 65 67 69 6e 7b |s case, |.\begin{|
|00004da0| 73 63 68 65 6d 65 7d 0a | 28 4d 20 31 20 32 29 20 |scheme}.|(M 1 2) |
|00004db0| 5c 6c 65 76 20 69 6e 74 | 65 67 65 72 2d 69 6e 74 |\lev int|eger-int|
|00004dc0| 65 67 65 72 0a 28 4d 20 | 31 20 31 2e 30 29 20 5c |eger.(M |1 1.0) \|
|00004dd0| 6c 65 76 20 69 6e 74 65 | 67 65 72 2d 72 65 61 6c |lev inte|ger-real|
|00004de0| 0a 28 4d 20 31 20 7b 5c | 73 63 68 74 72 75 65 7d |.(M 1 {\|schtrue}|
|00004df0| 29 20 5c 6c 65 76 20 69 | 6e 74 65 67 65 72 0a 28 |) \lev i|nteger.(|
|00004e00| 4d 20 27 61 20 31 29 20 | 5c 6c 65 76 20 27 74 6f |M 'a 1) |\lev 'to|
|00004e10| 70 2d 6e 75 6d 62 65 72 | 0a 5c 65 6e 64 7b 73 63 |p-number|.\end{sc|
|00004e20| 68 65 6d 65 7d 0a 0a 5c | 73 75 62 73 65 63 74 69 |heme}..\|subsecti|
|00004e30| 6f 6e 7b 4e 65 78 74 2d | 6d 65 74 68 6f 64 7d 0a |on{Next-|method}.|
|00004e40| 0a 57 68 65 6e 20 61 20 | 67 65 6e 65 72 69 63 20 |.When a |generic |
|00004e50| 66 75 6e 63 74 69 6f 6e | 20 69 73 20 63 61 6c 6c |function| is call|
|00004e60| 65 64 2c 20 74 68 65 20 | 6c 69 73 74 20 6f 66 20 |ed, the |list of |
|00004e70| 61 70 70 6c 69 63 61 62 | 6c 65 20 6d 65 74 68 6f |applicab|le metho|
|00004e80| 64 73 20 69 73 20 62 75 | 69 6c 74 2e 20 41 73 0a |ds is bu|ilt. As.|
|00004e90| 6d 65 6e 74 69 6f 6e 65 | 64 20 62 65 66 6f 72 65 |mentione|d before|
|00004ea0| 2c 20 74 68 65 20 6d 6f | 73 74 20 73 70 65 63 69 |, the mo|st speci|
|00004eb0| 66 69 63 20 6d 65 74 68 | 6f 64 20 6f 66 20 74 68 |fic meth|od of th|
|00004ec0| 69 73 20 6c 69 73 74 20 | 69 73 20 61 70 70 6c 69 |is list |is appli|
|00004ed0| 65 64 0a 28 73 65 65 7e | 5c 72 65 66 7b 67 66 2d |ed.(see~|\ref{gf-|
|00004ee0| 6e 2d 6d 65 74 68 6f 64 | 73 7d 29 2e 20 54 68 69 |n-method|s}). Thi|
|00004ef0| 73 20 6d 65 74 68 6f 64 | 20 6d 61 79 20 63 61 6c |s method| may cal|
|00004f00| 6c 20 74 68 65 20 6e 65 | 78 74 20 6d 65 74 68 6f |l the ne|xt metho|
|00004f10| 64 20 69 6e 0a 74 68 65 | 20 6c 69 73 74 20 6f 66 |d in.the| list of|
|00004f20| 20 61 70 70 6c 69 63 61 | 62 6c 65 20 6d 65 74 68 | applica|ble meth|
|00004f30| 6f 64 73 2e 20 54 68 69 | 73 20 69 73 20 64 6f 6e |ods. Thi|s is don|
|00004f40| 65 20 62 79 20 75 73 69 | 6e 67 20 74 68 65 20 73 |e by usi|ng the s|
|00004f50| 70 65 63 69 61 6c 20 66 | 6f 72 6d 0a 5c 69 64 65 |pecial f|orm.\ide|
|00004f60| 7b 6e 65 78 74 2d 6d 65 | 74 68 6f 64 7d 2e 20 43 |{next-me|thod}. C|
|00004f70| 6f 6e 73 69 64 65 72 20 | 74 68 65 20 66 6f 6c 6c |onsider |the foll|
|00004f80| 6f 77 69 6e 67 20 64 65 | 66 69 6e 69 74 69 6f 6e |owing de|finition|
|00004f90| 73 0a 5c 62 65 67 69 6e | 7b 73 63 68 65 6d 65 7d |s.\begin|{scheme}|
|00004fa0| 0a 28 64 65 66 69 6e 65 | 2d 6d 65 74 68 6f 64 20 |.(define|-method |
|00004fb0| 54 65 73 74 28 28 61 20 | 3c 69 6e 74 65 67 65 72 |Test((a |<integer|
|00004fc0| 3e 29 29 20 20 28 63 6f | 6e 73 20 27 69 6e 74 65 |>)) (co|ns 'inte|
|00004fd0| 67 65 72 20 28 6e 65 78 | 74 2d 6d 65 74 68 6f 64 |ger (nex|t-method|
|00004fe0| 29 29 29 0a 28 64 65 66 | 69 6e 65 2d 6d 65 74 68 |))).(def|ine-meth|
|00004ff0| 6f 64 20 54 65 73 74 28 | 28 61 20 3c 6e 75 6d 62 |od Test(|(a <numb|
|00005000| 65 72 3e 29 29 20 20 20 | 28 63 6f 6e 73 20 27 6e |er>)) |(cons 'n|
|00005010| 75 6d 62 65 72 20 20 28 | 6e 65 78 74 2d 6d 65 74 |umber (|next-met|
|00005020| 68 6f 64 29 29 29 0a 28 | 64 65 66 69 6e 65 2d 6d |hod))).(|define-m|
|00005030| 65 74 68 6f 64 20 54 65 | 73 74 28 61 29 09 09 20 |ethod Te|st(a).. |
|00005040| 20 20 20 28 6c 69 73 74 | 20 27 74 6f 70 29 29 0a | (list| 'top)).|
|00005050| 5c 65 6e 64 7b 73 63 68 | 65 6d 65 7d 0a 0a 57 69 |\end{sch|eme}..Wi|
|00005060| 74 68 20 74 68 6f 73 65 | 20 64 65 66 69 6e 69 74 |th those| definit|
|00005070| 69 6f 6e 73 2c 0a 5c 62 | 65 67 69 6e 7b 73 63 68 |ions,.\b|egin{sch|
|00005080| 65 6d 65 7d 0a 28 54 65 | 73 74 20 31 29 20 5c 6c |eme}.(Te|st 1) \l|
|00005090| 65 76 20 28 69 6e 74 65 | 67 65 72 20 6e 75 6d 62 |ev (inte|ger numb|
|000050a0| 65 72 20 74 6f 70 29 0a | 28 54 65 73 74 20 31 2e |er top).|(Test 1.|
|000050b0| 30 29 20 5c 6c 65 76 20 | 28 6e 75 6d 62 65 72 20 |0) \lev |(number |
|000050c0| 74 6f 70 29 0a 28 54 65 | 73 74 20 5c 73 63 68 74 |top).(Te|st \scht|
|000050d0| 72 75 65 29 20 5c 6c 65 | 76 20 28 74 6f 70 29 0a |rue) \le|v (top).|
|000050e0| 5c 65 6e 64 7b 73 63 68 | 65 6d 65 7d 0a 0a 5c 73 |\end{sch|eme}..\s|
|000050f0| 75 62 73 65 63 74 69 6f | 6e 7b 45 78 61 6d 70 6c |ubsectio|n{Exampl|
|00005100| 65 7d 20 0a 0a 49 6e 20 | 74 68 69 73 20 73 65 63 |e} ..In |this sec|
|00005110| 74 69 6f 6e 20 77 65 20 | 73 68 61 6c 6c 20 63 6f |tion we |shall co|
|00005120| 6e 74 69 6e 75 65 20 74 | 6f 20 64 65 66 69 6e 65 |ntinue t|o define|
|00005130| 20 6f 70 65 72 61 74 69 | 6f 6e 73 20 6f 6e 20 74 | operati|ons on t|
|00005140| 68 65 20 7b 5c 74 74 20 | 3c 63 6f 6d 70 6c 65 78 |he {\tt |<complex|
|00005150| 3e 7d 0a 63 6c 61 73 73 | 20 64 65 66 69 6e 65 64 |>}.class| defined|
|00005160| 20 69 6e 20 46 69 67 75 | 72 65 7e 32 2e 20 53 75 | in Figu|re~2. Su|
|00005170| 70 70 6f 73 65 20 74 68 | 61 74 20 77 65 20 77 61 |ppose th|at we wa|
|00005180| 6e 74 20 74 6f 20 75 73 | 65 20 69 74 20 74 6f 20 |nt to us|e it to |
|00005190| 69 6d 70 6c 65 6d 65 6e | 74 20 0a 63 6f 6d 70 6c |implemen|t .compl|
|000051a0| 65 78 20 6e 75 6d 62 65 | 72 73 20 63 6f 6d 70 6c |ex numbe|rs compl|
|000051b0| 65 74 65 6c 79 2e 20 46 | 6f 72 20 69 6e 73 74 61 |etely. F|or insta|
|000051c0| 6e 63 65 20 61 20 64 65 | 66 69 6e 69 74 69 6f 6e |nce a de|finition|
|000051d0| 20 66 6f 72 20 74 68 65 | 20 61 64 64 69 74 69 6f | for the| additio|
|000051e0| 6e 20 6f 66 20 0a 74 77 | 6f 20 63 6f 6d 70 6c 65 |n of .tw|o comple|
|000051f0| 78 65 73 20 63 6f 75 6c | 64 20 62 65 0a 5c 62 65 |xes coul|d be.\be|
|00005200| 67 69 6e 7b 73 63 68 65 | 6d 65 7d 0a 28 64 65 66 |gin{sche|me}.(def|
|00005210| 69 6e 65 2d 6d 65 74 68 | 6f 64 20 6e 65 77 2d 2b |ine-meth|od new-+|
|00005220| 20 28 28 61 20 3c 63 6f | 6d 70 6c 65 78 3e 29 20 | ((a <co|mplex>) |
|00005230| 28 62 20 3c 63 6f 6d 70 | 6c 65 78 3e 29 29 0a 20 |(b <comp|lex>)). |
|00005240| 20 28 6d 61 6b 65 2d 72 | 65 63 74 61 6e 67 75 6c | (make-r|ectangul|
|00005250| 61 72 20 28 2b 20 28 72 | 65 61 6c 2d 70 61 72 74 |ar (+ (r|eal-part|
|00005260| 20 61 29 20 28 72 65 61 | 6c 2d 70 61 72 74 20 62 | a) (rea|l-part b|
|00005270| 29 29 0a 20 20 20 20 20 | 20 20 20 20 20 20 20 20 |)). | |
|00005280| 20 20 20 20 20 20 20 28 | 2b 20 28 69 6d 61 67 2d | (|+ (imag-|
|00005290| 70 61 72 74 20 61 29 20 | 28 69 6d 61 67 2d 70 61 |part a) |(imag-pa|
|000052a0| 72 74 20 62 29 29 29 29 | 0a 5c 65 6e 64 7b 73 63 |rt b))))|.\end{sc|
|000052b0| 68 65 6d 65 7d 0a 0a 54 | 6f 20 62 65 20 73 75 72 |heme}..T|o be sur|
|000052c0| 65 20 74 68 61 74 20 74 | 68 65 20 7b 5c 74 74 20 |e that t|he {\tt |
|000052d0| 2b 7d 20 75 73 65 64 20 | 69 6e 20 74 68 65 20 6d |+} used |in the m|
|000052e0| 65 74 68 6f 64 20 7b 5c | 74 74 20 6e 65 77 2d 2b |ethod {\|tt new-+|
|000052f0| 7d 20 69 73 20 74 68 65 | 20 73 74 61 6e 64 61 72 |} is the| standar|
|00005300| 64 0a 61 64 64 69 74 69 | 6f 6e 20 77 65 20 63 61 |d.additi|on we ca|
|00005310| 6e 20 64 6f 3a 0a 5c 62 | 65 67 69 6e 7b 73 63 68 |n do:.\b|egin{sch|
|00005320| 65 6d 65 7d 0a 28 64 65 | 66 69 6e 65 2d 67 65 6e |eme}.(de|fine-gen|
|00005330| 65 72 69 63 20 6e 65 77 | 2d 2b 29 0a 0a 28 6c 65 |eric new|-+)..(le|
|00005340| 74 20 28 28 2b 20 2b 29 | 29 0a 20 20 28 64 65 66 |t ((+ +)|). (def|
|00005350| 69 6e 65 2d 6d 65 74 68 | 6f 64 20 6e 65 77 2d 2b |ine-meth|od new-+|
|00005360| 20 28 28 61 20 3c 63 6f | 6d 70 6c 65 78 3e 29 20 | ((a <co|mplex>) |
|00005370| 28 62 20 3c 63 6f 6d 70 | 6c 65 78 3e 29 29 0a 20 |(b <comp|lex>)). |
|00005380| 20 20 20 28 6d 61 6b 65 | 2d 72 65 63 74 61 6e 67 | (make|-rectang|
|00005390| 75 6c 61 72 20 28 2b 20 | 28 72 65 61 6c 2d 70 61 |ular (+ |(real-pa|
|000053a0| 72 74 20 61 29 20 28 72 | 65 61 6c 2d 70 61 72 74 |rt a) (r|eal-part|
|000053b0| 20 62 29 29 0a 20 20 20 | 20 20 20 20 20 20 20 20 | b)). | |
|000053c0| 20 20 20 20 20 20 20 20 | 20 20 20 28 2b 20 28 69 | | (+ (i|
|000053d0| 6d 61 67 2d 70 61 72 74 | 20 61 29 20 28 69 6d 61 |mag-part| a) (ima|
|000053e0| 67 2d 70 61 72 74 20 62 | 29 29 29 29 29 0a 5c 65 |g-part b|))))).\e|
|000053f0| 6e 64 7b 73 63 68 65 6d | 65 7d 0a 0a 54 68 65 20 |nd{schem|e}..The |
|00005400| 7b 5c 74 74 20 64 65 66 | 69 6e 65 2d 67 65 6e 65 |{\tt def|ine-gene|
|00005410| 72 69 63 7d 20 65 6e 73 | 75 72 65 73 20 68 65 72 |ric} ens|ures her|
|00005420| 65 20 74 68 61 74 20 7b | 5c 74 74 20 6e 65 77 2d |e that {|\tt new-|
|00005430| 2b 7d 20 77 69 6c 6c 20 | 62 65 20 64 65 66 69 6e |+} will |be defin|
|00005440| 65 64 20 69 6e 20 74 68 | 65 20 67 6c 6f 62 61 6c |ed in th|e global|
|00005450| 0a 65 6e 76 69 72 6f 6e | 6d 65 6e 74 2e 20 4f 6e |.environ|ment. On|
|00005460| 63 65 20 74 68 69 73 20 | 69 73 20 64 6f 6e 65 2c |ce this |is done,|
|00005470| 20 77 65 20 63 61 6e 20 | 61 64 64 20 6d 65 74 68 | we can |add meth|
|00005480| 6f 64 73 20 74 6f 20 74 | 68 65 20 67 65 6e 65 72 |ods to t|he gener|
|00005490| 69 63 20 66 75 6e 63 74 | 69 6f 6e 20 0a 7b 5c 74 |ic funct|ion .{\t|
|000054a0| 74 20 6e 65 77 2d 2b 7d | 20 77 68 69 63 68 20 6d |t new-+}| which m|
|000054b0| 61 6b 65 20 61 20 63 6c | 6f 73 75 72 65 20 6f 6e |ake a cl|osure on|
|000054c0| 20 74 68 65 20 7b 5c 74 | 74 20 2b 7d 20 73 79 6d | the {\t|t +} sym|
|000054d0| 62 6f 6c 2e 0a 41 20 63 | 6f 6d 70 6c 65 74 65 20 |bol..A c|omplete |
|000054e0| 77 72 69 74 69 6e 67 20 | 6f 66 20 74 68 65 20 7b |writing |of the {|
|000054f0| 5c 74 74 20 6e 65 77 2d | 2b 7d 20 6d 65 74 68 6f |\tt new-|+} metho|
|00005500| 64 73 20 69 73 20 73 68 | 6f 77 6e 20 69 6e 20 46 |ds is sh|own in F|
|00005510| 69 67 75 72 65 7e 33 2e | 0a 0a 5c 62 65 67 69 6e |igure~3.|..\begin|
|00005520| 7b 66 69 67 75 72 65 7d | 0a 7b 5c 66 6f 6f 74 6e |{figure}|.{\footn|
|00005530| 6f 74 65 73 69 7a 65 0a | 5c 62 65 67 69 6e 7b 71 |otesize.|\begin{q|
|00005540| 75 6f 74 65 7d 0a 5c 62 | 65 67 69 6e 7b 71 75 6f |uote}.\b|egin{quo|
|00005550| 74 65 7d 0a 5c 62 65 67 | 69 6e 7b 76 65 72 62 61 |te}.\beg|in{verba|
|00005560| 74 69 6d 7d 0a 28 64 65 | 66 69 6e 65 2d 67 65 6e |tim}.(de|fine-gen|
|00005570| 65 72 69 63 20 6e 65 77 | 2d 2b 29 0a 0a 28 6c 65 |eric new|-+)..(le|
|00005580| 74 20 28 28 2b 20 2b 29 | 29 0a 0a 20 20 28 64 65 |t ((+ +)|).. (de|
|00005590| 66 69 6e 65 2d 6d 65 74 | 68 6f 64 20 6e 65 77 2d |fine-met|hod new-|
|000055a0| 2b 20 28 28 61 20 3c 72 | 65 61 6c 3e 29 20 28 62 |+ ((a <r|eal>) (b|
|000055b0| 20 3c 72 65 61 6c 3e 29 | 29 20 28 2b 20 61 20 62 | <real>)|) (+ a b|
|000055c0| 29 29 0a 0a 20 20 28 64 | 65 66 69 6e 65 2d 6d 65 |)).. (d|efine-me|
|000055d0| 74 68 6f 64 20 6e 65 77 | 2d 2b 20 28 28 61 20 3c |thod new|-+ ((a <|
|000055e0| 72 65 61 6c 3e 29 20 28 | 62 20 3c 63 6f 6d 70 6c |real>) (|b <compl|
|000055f0| 65 78 3e 29 29 20 0a 20 | 20 20 20 28 6d 61 6b 65 |ex>)) . | (make|
|00005600| 2d 72 65 63 74 61 6e 67 | 75 6c 61 72 20 28 2b 20 |-rectang|ular (+ |
|00005610| 61 20 28 72 65 61 6c 2d | 70 61 72 74 20 62 29 29 |a (real-|part b))|
|00005620| 20 28 69 6d 61 67 2d 70 | 61 72 74 20 62 29 29 29 | (imag-p|art b)))|
|00005630| 0a 0a 20 20 28 64 65 66 | 69 6e 65 2d 6d 65 74 68 |.. (def|ine-meth|
|00005640| 6f 64 20 6e 65 77 2d 2b | 20 28 28 61 20 3c 63 6f |od new-+| ((a <co|
|00005650| 6d 70 6c 65 78 3e 29 20 | 28 62 20 3c 72 65 61 6c |mplex>) |(b <real|
|00005660| 3e 29 29 0a 20 20 20 20 | 28 6d 61 6b 65 2d 72 65 |>)). |(make-re|
|00005670| 63 74 61 6e 67 75 6c 61 | 72 20 28 2b 20 28 72 65 |ctangula|r (+ (re|
|00005680| 61 6c 2d 70 61 72 74 20 | 61 29 20 62 29 20 28 69 |al-part |a) b) (i|
|00005690| 6d 61 67 2d 70 61 72 74 | 20 61 29 29 29 0a 0a 20 |mag-part| a))).. |
|000056a0| 20 28 64 65 66 69 6e 65 | 2d 6d 65 74 68 6f 64 20 | (define|-method |
|000056b0| 6e 65 77 2d 2b 20 28 28 | 61 20 3c 63 6f 6d 70 6c |new-+ ((|a <compl|
|000056c0| 65 78 3e 29 20 28 62 20 | 3c 63 6f 6d 70 6c 65 78 |ex>) (b |<complex|
|000056d0| 3e 29 29 0a 20 20 20 20 | 28 6d 61 6b 65 2d 72 65 |>)). |(make-re|
|000056e0| 63 74 61 6e 67 75 6c 61 | 72 20 28 2b 20 28 72 65 |ctangula|r (+ (re|
|000056f0| 61 6c 2d 70 61 72 74 20 | 61 29 20 28 72 65 61 6c |al-part |a) (real|
|00005700| 2d 70 61 72 74 20 62 29 | 29 0a 20 20 20 20 20 20 |-part b)|). |
|00005710| 20 20 20 20 20 20 20 20 | 20 20 20 20 20 20 20 20 | | |
|00005720| 28 2b 20 28 69 6d 61 67 | 2d 70 61 72 74 20 61 29 |(+ (imag|-part a)|
|00005730| 20 28 69 6d 61 67 2d 70 | 61 72 74 20 62 29 29 29 | (imag-p|art b)))|
|00005740| 29 0a 0a 20 20 28 64 65 | 66 69 6e 65 2d 6d 65 74 |).. (de|fine-met|
|00005750| 68 6f 64 20 6e 65 77 2d | 2b 20 28 28 61 20 3c 6e |hod new-|+ ((a <n|
|00005760| 75 6d 62 65 72 3e 29 29 | 20 20 61 29 0a 20 20 0a |umber>))| a). .|
|00005770| 20 20 28 64 65 66 69 6e | 65 2d 6d 65 74 68 6f 64 | (defin|e-method|
|00005780| 20 6e 65 77 2d 2b 20 28 | 29 20 30 29 0a 0a 20 20 | new-+ (|) 0).. |
|00005790| 28 64 65 66 69 6e 65 2d | 6d 65 74 68 6f 64 20 6e |(define-|method n|
|000057a0| 65 77 2d 2b 20 61 72 67 | 73 20 20 28 6e 65 77 2d |ew-+ arg|s (new-|
|000057b0| 2b 20 28 63 61 72 20 61 | 72 67 73 29 20 28 61 70 |+ (car a|rgs) (ap|
|000057c0| 70 6c 79 20 6e 65 77 2d | 2b 20 28 63 64 72 20 61 |ply new-|+ (cdr a|
|000057d0| 72 67 73 29 29 29 29 29 | 0a 0a 28 73 65 74 21 20 |rgs)))))|..(set! |
|000057e0| 2b 20 6e 65 77 2d 2b 29 | 0a 5c 65 6e 64 7b 76 65 |+ new-+)|.\end{ve|
|000057f0| 72 62 61 74 69 6d 7d 0a | 5c 63 61 70 74 69 6f 6e |rbatim}.|\caption|
|00005800| 7b 5c 65 6d 20 45 78 74 | 65 6e 64 69 6e 67 20 7b |{\em Ext|ending {|
|00005810| 5c 74 74 20 2b 7d 20 66 | 6f 72 20 64 65 61 6c 69 |\tt +} f|or deali|
|00005820| 6e 67 20 77 69 74 68 20 | 63 6f 6d 70 6c 65 78 20 |ng with |complex |
|00005830| 6e 75 6d 62 65 72 73 7d | 0a 5c 65 6e 64 7b 71 75 |numbers}|.\end{qu|
|00005840| 6f 74 65 7d 0a 5c 65 6e | 64 7b 71 75 6f 74 65 7d |ote}.\en|d{quote}|
|00005850| 0a 7d 0a 5c 65 6e 64 7b | 66 69 67 75 72 65 7d 0a |.}.\end{|figure}.|
|00005860| 0a 5c 62 69 67 73 6b 69 | 70 0a 57 65 20 75 73 65 |.\bigski|p.We use|
|00005870| 20 68 65 72 65 20 74 68 | 65 20 66 61 63 74 20 74 | here th|e fact t|
|00005880| 68 61 74 20 67 65 6e 65 | 72 69 63 20 66 75 6e 63 |hat gene|ric func|
|00005890| 74 69 6f 6e 20 61 72 65 | 20 6e 6f 74 20 6f 62 6c |tion are| not obl|
|000058a0| 69 67 65 64 20 74 6f 20 | 68 61 76 65 20 74 68 65 |iged to |have the|
|000058b0| 20 73 61 6d 65 0a 6e 75 | 6d 62 65 72 20 6f 66 20 | same.nu|mber of |
|000058c0| 70 61 72 61 6d 65 74 65 | 72 73 2c 20 63 6f 6e 74 |paramete|rs, cont|
|000058d0| 72 61 72 69 6c 79 20 74 | 6f 20 43 4c 4f 53 2e 20 |rarily t|o CLOS. |
|000058e0| 20 54 68 65 20 66 6f 75 | 72 20 66 69 72 73 74 20 | The fou|r first |
|000058f0| 6d 65 74 68 6f 64 73 0a | 69 6d 70 6c 65 6d 65 6e |methods.|implemen|
|00005900| 74 20 74 68 65 20 64 79 | 61 64 69 63 20 61 64 64 |t the dy|adic add|
|00005910| 69 74 69 6f 6e 2e 20 54 | 68 65 20 66 69 66 74 68 |ition. T|he fifth|
|00005920| 20 6d 65 74 68 6f 64 20 | 73 61 79 73 20 74 68 61 | method |says tha|
|00005930| 74 20 74 68 65 20 61 64 | 64 69 74 69 6f 6e 20 6f |t the ad|dition o|
|00005940| 66 20 61 20 73 69 6e 67 | 6c 65 0a 65 6c 65 6d 65 |f a sing|le.eleme|
|00005950| 6e 74 20 69 73 20 74 68 | 69 73 20 65 6c 65 6d 65 |nt is th|is eleme|
|00005960| 6e 74 20 69 74 73 65 6c | 66 2e 20 54 68 65 20 73 |nt itsel|f. The s|
|00005970| 69 78 74 68 20 6d 65 74 | 68 6f 64 20 73 61 79 73 |ixth met|hod says|
|00005980| 20 74 68 61 74 20 75 73 | 69 6e 67 20 74 68 65 20 | that us|ing the |
|00005990| 61 64 64 69 74 69 6f 6e | 20 77 69 74 68 0a 6e 6f |addition| with.no|
|000059a0| 20 70 61 72 61 6d 65 74 | 65 72 20 61 6c 77 61 79 | paramet|er alway|
|000059b0| 73 20 72 65 74 75 72 6e | 20 30 2e 20 54 68 65 20 |s return| 0. The |
|000059c0| 6c 61 73 74 20 6d 65 74 | 68 6f 64 20 74 61 6b 65 |last met|hod take|
|000059d0| 73 20 61 6e 20 61 72 62 | 69 74 72 61 72 79 20 6e |s an arb|itrary n|
|000059e0| 75 6d 62 65 72 20 6f 66 | 0a 70 61 72 61 6d 65 74 |umber of|.paramet|
|000059f0| 65 72 73 5c 66 6f 6f 74 | 6e 6f 74 65 7b 54 68 65 |ers\foot|note{The|
|00005a00| 20 74 68 69 72 64 20 70 | 61 72 61 6d 65 74 65 72 | third p|arameter|
|00005a10| 20 6f 66 20 61 20 64 65 | 66 69 6e 65 2d 6d 65 74 | of a de|fine-met|
|00005a20| 68 6f 64 20 69 73 20 61 | 20 70 61 72 61 6d 65 74 |hod is a| paramet|
|00005a30| 65 72 20 6c 69 73 74 0a | 77 68 69 63 68 20 66 6f |er list.|which fo|
|00005a40| 6c 6c 6f 77 20 74 68 65 | 20 63 6f 6e 76 65 6e 74 |llow the| convent|
|00005a50| 69 6f 6e 73 20 75 73 65 | 64 20 66 6f 72 20 6c 61 |ions use|d for la|
|00005a60| 6d 62 64 61 20 65 78 70 | 72 65 73 73 69 6f 6e 73 |mbda exp|ressions|
|00005a70| 2e 20 49 6e 20 70 61 72 | 74 69 63 75 6c 61 72 20 |. In par|ticular |
|00005a80| 69 74 20 63 61 6e 0a 75 | 73 65 20 74 68 65 20 64 |it can.u|se the d|
|00005a90| 6f 74 20 6e 6f 74 61 74 | 69 6f 6e 20 6f 72 20 61 |ot notat|ion or a|
|00005aa0| 20 73 79 6d 62 6f 6c 20 | 74 6f 20 64 65 6e 6f 74 | symbol |to denot|
|00005ab0| 65 20 61 6e 20 61 72 62 | 69 74 72 61 72 79 20 6e |e an arb|itrary n|
|00005ac0| 75 6d 62 65 72 20 6f 66 | 20 70 61 72 61 6d 65 74 |umber of| paramet|
|00005ad0| 65 72 73 7d 2e 0a 54 68 | 69 73 20 6d 65 74 68 6f |ers}..Th|is metho|
|00005ae0| 64 20 61 63 74 73 20 61 | 73 20 61 20 6b 69 6e 64 |d acts a|s a kind|
|00005af0| 20 6f 66 20 7b 5c 74 74 | 20 72 65 64 75 63 65 7d | of {\tt| reduce}|
|00005b00| 3a 20 69 74 20 63 61 6c | 6c 73 20 74 68 65 20 64 |: it cal|ls the d|
|00005b10| 79 61 64 69 63 20 61 64 | 64 69 74 69 6f 6e 20 6f |yadic ad|dition o|
|00005b20| 6e 0a 74 68 65 20 7b 5c | 65 6d 20 63 61 72 7d 20 |n.the {\|em car} |
|00005b30| 6f 66 20 74 68 65 20 6c | 69 73 74 20 61 6e 64 20 |of the l|ist and |
|00005b40| 6f 6e 20 74 68 65 20 72 | 65 73 75 6c 74 20 6f 66 |on the r|esult of|
|00005b50| 20 61 70 70 6c 79 69 6e | 67 20 69 74 20 6f 6e 20 | applyin|g it on |
|00005b60| 69 74 73 20 72 65 73 74 | 2e 20 20 54 6f 0a 66 69 |its rest|. To.fi|
|00005b70| 6e 69 73 68 2c 20 74 68 | 65 20 7b 5c 74 74 20 73 |nish, th|e {\tt s|
|00005b80| 65 74 21 7d 20 70 65 72 | 6d 69 74 73 20 74 6f 20 |et!} per|mits to |
|00005b90| 72 65 64 65 66 69 6e 65 | 20 74 68 65 20 7b 5c 74 |redefine| the {\t|
|00005ba0| 74 20 2b 20 73 79 6d 62 | 6f 6c 7d 20 74 6f 20 6f |t + symb|ol} to o|
|00005bb0| 75 72 20 65 78 74 65 6e | 64 65 64 0a 61 64 64 69 |ur exten|ded.addi|
|00005bc0| 74 69 6f 6e 2e 0a 0a 5c | 62 69 67 73 6b 69 70 0a |tion...\|bigskip.|
|00005bd0| 54 6f 20 74 65 72 6d 69 | 6e 61 74 65 20 6f 75 72 |To termi|nate our|
|00005be0| 20 69 6d 70 6c 65 6d 65 | 6e 74 61 74 69 6f 6e 20 | impleme|ntation |
|00005bf0| 28 69 6e 74 65 67 72 61 | 74 69 6f 6e 3f 29 20 6f |(integra|tion?) o|
|00005c00| 66 20 20 63 6f 6d 70 6c | 65 78 20 6e 75 6d 62 65 |f compl|ex numbe|
|00005c10| 72 73 2c 20 77 65 20 63 | 61 6e 20 0a 72 65 64 65 |rs, we c|an .rede|
|00005c20| 66 69 6e 65 20 73 74 61 | 6e 64 61 72 64 20 53 63 |fine sta|ndard Sc|
|00005c30| 68 65 6d 65 20 70 72 65 | 64 69 63 61 74 65 73 20 |heme pre|dicates |
|00005c40| 69 6e 20 74 68 65 20 66 | 6f 6c 6c 6f 77 69 6e 67 |in the f|ollowing|
|00005c50| 20 6d 61 6e 6e 65 72 3a | 0a 5c 62 65 67 69 6e 7b | manner:|.\begin{|
|00005c60| 73 63 68 65 6d 65 7d 0a | 28 64 65 66 69 6e 65 2d |scheme}.|(define-|
|00005c70| 6d 65 74 68 6f 64 20 63 | 6f 6d 70 6c 65 78 3f 20 |method c|omplex? |
|00005c80| 28 63 20 3c 63 6f 6d 70 | 6c 65 78 3e 29 20 5c 73 |(c <comp|lex>) \s|
|00005c90| 63 68 74 72 75 65 29 0a | 28 64 65 66 69 6e 65 2d |chtrue).|(define-|
|00005ca0| 6d 65 74 68 6f 64 20 63 | 6f 6d 70 6c 65 78 3f 20 |method c|omplex? |
|00005cb0| 28 63 29 20 20 20 20 20 | 20 20 20 20 20 20 5c 73 |(c) | \s|
|00005cc0| 63 68 66 61 6c 73 65 29 | 0a 0a 28 64 65 66 69 6e |chfalse)|..(defin|
|00005cd0| 65 2d 6d 65 74 68 6f 64 | 20 6e 75 6d 62 65 72 3f |e-method| number?|
|00005ce0| 20 28 6e 20 3c 6e 75 6d | 62 65 72 3e 29 20 5c 73 | (n <num|ber>) \s|
|00005cf0| 63 68 74 72 75 65 29 0a | 28 64 65 66 69 6e 65 2d |chtrue).|(define-|
|00005d00| 6d 65 74 68 6f 64 20 6e | 75 6d 62 65 72 3f 20 28 |method n|umber? (|
|00005d10| 6e 29 20 20 20 20 20 20 | 20 20 20 20 5c 73 63 68 |n) | \sch|
|00005d20| 66 61 6c 73 65 29 0a 2e | 2e 2e 0a 2e 2e 2e 0a 5c |false)..|.......\|
|00005d30| 65 6e 64 7b 73 63 68 65 | 6d 65 7d 0a 0a 53 74 61 |end{sche|me}..Sta|
|00005d40| 6e 64 61 72 64 20 70 72 | 69 6d 69 74 69 76 65 73 |ndard pr|imitives|
|00005d50| 20 69 6e 20 77 68 69 63 | 68 20 63 6f 6d 70 6c 65 | in whic|h comple|
|00005d60| 78 20 6e 75 6d 62 65 72 | 73 20 61 72 65 20 69 6e |x number|s are in|
|00005d70| 76 6f 6c 76 65 64 20 63 | 6f 75 6c 64 20 61 6c 73 |volved c|ould als|
|00005d80| 6f 20 62 65 20 72 65 64 | 65 66 69 6e 65 64 0a 69 |o be red|efined.i|
|00005d90| 6e 20 74 68 65 20 73 61 | 6d 65 20 6d 61 6e 6e 65 |n the sa|me manne|
|00005da0| 72 2e 0a 0a 54 68 69 73 | 20 65 6e 64 73 20 74 68 |r...This| ends th|
|00005db0| 69 73 20 62 72 69 65 66 | 20 70 72 65 73 65 6e 74 |is brief| present|
|00005dc0| 61 74 69 6f 6e 20 6f 66 | 20 74 68 65 20 7b 5c 73 |ation of| the {\s|
|00005dd0| 74 6b 6c 6f 73 7d 20 65 | 78 74 65 6e 73 69 6f 6e |tklos} e|xtension|
|00005de0| 2e 20 20 0a | |. . | |
+--------+-------------------------+-------------------------+--------+--------+